From: Dan White Date: Fri, 24 Feb 2012 21:08:26 +0000 (-0600) Subject: Add script to ensure a footprint's description matches filename X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=32960e6cba9facb208d2526f496fc36e14337160;p=waeda-fp.git Add script to ensure a footprint's description matches filename --- diff --git a/fpfixup.py b/fpfixup.py new file mode 100755 index 0000000..c77184a --- /dev/null +++ b/fpfixup.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + + +import sys +from os.path import basename + +if len(sys.argv) < 2: + print 'usage: %s file0 [file1 [file2...]]' % sys.argv[0] + sys.exit(1) + +for fpath in sys.argv[1:]: + fname = basename(fpath) + + fp = open(fpath) + lines = fp.readlines() + fp.close() + if lines[0][0:7] == 'Element': + fields = lines[0].split() + if fields[1] == fname or fields[1] == '"'+fname+'"': + print 'Not touching:', fpath + else: + fields[1] = '"%s"' % fname + #put back the split() trailing newline + lines[0] = ' '.join(fields) + '\n' + print 'Rewriting:', fpath + open(fpath, 'w').write(''.join(lines)) +