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 @@
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':
......
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