/usr/share/fritzing/parts/scripts/schemobs.py is in fritzing-parts 0.9.3b-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | import getopt, sys, os, re
def usage():
print """
usage:
schemobs.py -f <fritzing folder> -h <hand drawn schematic folder> -g <generated schematics folder>
in the <parts folder>/svg/core/schematic folder match files from the -h and -g folders
print the list of files unaccounted for in -f and -g
ignore the ones that start with sparkfun-
"""
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "h:g:f:", ["hand", "generated", "fritzing"])
except getopt.GetoptError, err:
# print help information and exit:
print str(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
fritzingDir = None
handDir = None
generatedDir = None
for o, a in opts:
#print o
#print a
if o in ("-h", "--hand"):
handDir = a
elif o in ("-g", "--generated"):
generatedDir = a
elif o in ("-f", "--fritzing"):
fritzingDir = a
else:
print "unhandled option", o
usage()
return
if not fritzingDir:
usage()
return
if not generatedDir:
usage()
return
if not handDir:
usage()
return
toMatch = []
schemDir = os.path.join(fritzingDir, "parts", "svg", "core", "schematic")
for filename in os.listdir(schemDir):
if filename.startswith("sparkfun-"):
continue
toMatch.append(filename)
for filename in os.listdir(handDir):
if not filename in toMatch:
print "unable to find {0} from hand".format(filename)
else:
toMatch.remove(filename)
for filename in os.listdir(generatedDir):
if not filename in toMatch:
print "unable to find {0} from generated".format(filename)
else:
toMatch.remove(filename)
print ""
pdbDir = os.path.join(fritzingDir, "pdb", "core")
fzps = []
for filename in os.listdir(pdbDir):
infile = open(os.path.join(pdbDir, filename), "r")
txt = infile.read()
infile.close()
for matchName in toMatch:
if matchName in txt:
print "no match for {0} in {1}".format(matchName, filename)
fzps.append(filename)
toMatch.remove(matchName)
break
print ""
for filename in fzps:
print filename
if __name__ == "__main__":
main()
|