diff options
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: |