Skip to content
Snippets Groups Projects
Commit 4fc941be authored by Krisjanis Rijnieks's avatar Krisjanis Rijnieks :lion_face:
Browse files

Add description test for lib parts

parent 6f130ff6
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
import os.path import os.path
from os import path from os import path
import mmap
libraryName = 'fab' libraryName = 'fab'
errorCount = 0 errorCount = 0
...@@ -25,7 +26,7 @@ def errorOnLine(lineNum, message): ...@@ -25,7 +26,7 @@ def errorOnLine(lineNum, message):
def checkPartName(partDEFName, partF1Name): def checkPartName(partDEFName, partF1Name):
if partF1Name != partDEFName: if partF1Name != partDEFName:
errorOnLine(lineNum, 'Part DEF name and F1 name do not match') errorOnLine(lineNum, 'Part DEF name and F1 name do not match')
def checkFootprint(lineNum, footprintField): def checkFootprint(lineNum, footprintField):
if footprintField == '': if footprintField == '':
return return
...@@ -34,13 +35,21 @@ def checkFootprint(lineNum, footprintField): ...@@ -34,13 +35,21 @@ def checkFootprint(lineNum, footprintField):
if parts[0] != libraryName: if parts[0] != libraryName:
errorOnLine(lineNum, 'Footprint library name is wrong') errorOnLine(lineNum, 'Footprint library name is wrong')
if len(parts) > 1: if len(parts) > 1:
footprintPath = libraryName + '.pretty/' + parts[1] + '.kicad_mod' footprintPath = libraryName + '.pretty/' + parts[1] + '.kicad_mod'
footFileExists = path.exists(footprintPath) footFileExists = path.exists(footprintPath)
if footFileExists != True: if footFileExists != True:
errorOnLine(lineNum, 'Footprint file does not exist: ' + footprintPath) 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: with open(libraryName + '.lib', 'r') as f:
lines = f.readlines() lines = f.readlines()
f.close() f.close()
...@@ -56,6 +65,7 @@ for l in lines: ...@@ -56,6 +65,7 @@ for l in lines:
words = line.split() words = line.split()
if words[0] == 'DEF': if words[0] == 'DEF':
partDefName = words[1] partDefName = words[1]
checkDescription(partDefName)
if words[0] == 'F1': if words[0] == 'F1':
checkPartName(partDefName, words[1].strip('"')) checkPartName(partDefName, words[1].strip('"'))
if words[0] == 'F2': if words[0] == 'F2':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment