From 2a44e256924a2cf19fe2548aaff88ad782b0d7b8 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Mon, 25 Mar 2013 19:29:51 +0100 Subject: subcan.py: minor adjustments --- subcan.py | 13 +++-- subcan.svg.in | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 181 insertions(+), 6 deletions(-) create mode 100644 subcan.svg.in diff --git a/subcan.py b/subcan.py index 40d476d..1f71fdf 100644 --- a/subcan.py +++ b/subcan.py @@ -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: diff --git a/subcan.svg.in b/subcan.svg.in new file mode 100644 index 0000000..645cebb --- /dev/null +++ b/subcan.svg.in @@ -0,0 +1,174 @@ + + + + + + + + + image/svg+xml + + + + + + + + soll + ist + 100% + 100% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100% + 100% + soll + ist + 100% + 100% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100% + 100% + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.1