diff options
author | Christian Franke <nobody@nowhere.ws> | 2013-03-25 19:29:51 +0100 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2013-03-25 19:29:51 +0100 |
commit | 2a44e256924a2cf19fe2548aaff88ad782b0d7b8 (patch) | |
tree | 47866907b7540002f8e6007c20aa1261d5f522a6 /subcan.py | |
parent | 27c8954bc7de4e1003cf4aa5ae8d5255b72e4920 (diff) |
subcan.py: minor adjustments
Diffstat (limited to 'subcan.py')
-rw-r--r-- | subcan.py | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -4,12 +4,12 @@ from lxml import etree from time import time, sleep def run(): - doc = etree.parse('subcan.svg') - data = json.loads(file('/home/services/http/subcan.json').read()) + doc = etree.parse('subcan.svg.in') + data = json.load(open('subcan.json','rb')) for i in ['door.left', 'door.right', 'door.lock']: cond = '%s=%s' % (i, data[i]['text']) - print cond + print >>sys.stderr, cond elems = doc.xpath('//svg:g[@inkscape:label="%s"]' % (cond,), namespaces = { 'svg': 'http://www.w3.org/2000/svg', @@ -27,7 +27,7 @@ def run(): namespaces = { 'svg': 'http://www.w3.org/2000/svg', }) - print 'elems for %s_%s: %d' % (i, j, len(elems)) + print >>sys.stderr, 'elems for %s_%s: %d' % (i, j, len(elems)) for e in elems: try: text = data[i][j] @@ -37,10 +37,11 @@ def run(): text = u'<?>' e.text = text except KeyError: - print 'error processing \'%s_%s\'' % (i, j) + print >>sys.stderr, 'error processing \'%s_%s\'' % (i, j) e.text = u'<?>' - file('/home/services/http/subcan.svg', 'w').write(etree.tostring(doc)) + with open('subcan.svg', 'wb') as subcan_svg: + subcan_svg.write(etree.tostring(doc)) while True: try: |