/usr/share/fritzing/parts/scripts/schemobscopy.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 | import getopt, sys, os, re, shutil
def usage():
print """
usage:
schemobscopy.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
copy the old files into obsolete with a prefix of "0.3.schem" and copy the new files into place
"""
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
for filename in os.listdir(handDir):
copyOne(filename, handDir, fritzingDir)
for filename in os.listdir(generatedDir):
copyOne(filename, generatedDir, fritzingDir)
def copyOne(filename, fromDir, fritzingDir):
schDir = os.path.join(fritzingDir, "parts", "svg", "core", "schematic")
obsDir = os.path.join(fritzingDir, "parts", "svg", "obsolete", "schematic")
try:
shutil.copy(os.path.join(schDir, filename), os.path.join(obsDir, "0.3.schem." + filename))
shutil.copy(os.path.join(fromDir, filename), os.path.join(schDir, filename))
except:
print "unable to copy", filename
if __name__ == "__main__":
main()
|