diff --git a/test.py b/test.py index 634abfec2d0544f7707929bf4ce0b9ac75593e2e..1823e2d4bd08b3bcbed5aacda520cb622432425f 100644 --- a/test.py +++ b/test.py @@ -13,6 +13,7 @@ import os.path from os import path +import mmap libraryName = 'fab' errorCount = 0 @@ -25,7 +26,7 @@ def errorOnLine(lineNum, message): def checkPartName(partDEFName, partF1Name): if partF1Name != partDEFName: errorOnLine(lineNum, 'Part DEF name and F1 name do not match') - + def checkFootprint(lineNum, footprintField): if footprintField == '': return @@ -34,13 +35,21 @@ def checkFootprint(lineNum, footprintField): if parts[0] != libraryName: errorOnLine(lineNum, 'Footprint library name is wrong') - + if len(parts) > 1: footprintPath = libraryName + '.pretty/' + parts[1] + '.kicad_mod' footFileExists = path.exists(footprintPath) if footFileExists != True: errorOnLine(lineNum, 'Footprint file does not exist: ' + footprintPath) +def checkDescription(symbolName): + with open(libraryName + '.dcm', 'r') as file, \ + mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) as s: + if s.find(symbolName.encode('utf8')) != -1: + return True + f.close() + errorOnLine(lineNum, 'Part description not found in .dcm file:' + symbolName) + with open(libraryName + '.lib', 'r') as f: lines = f.readlines() f.close() @@ -56,6 +65,7 @@ for l in lines: words = line.split() if words[0] == 'DEF': partDefName = words[1] + checkDescription(partDefName) if words[0] == 'F1': checkPartName(partDefName, words[1].strip('"')) if words[0] == 'F2':