8 for arg in sys.argv[1:]:
15 # example input: ./openinghours.py lang=cs 'xptr=1,4;1-2|2,3;3-4:35'
25 'sv': u'Öppningstider',
26 'de': u'Öffnungszeiten',
27 'en': u'Opening hours',
28 'cs': u'Otevírací doba',
44 loc = locale.getlocale()
45 locale.setlocale(locale.LC_ALL, loc_alias[lang])
46 day_names = [ locale.nl_langinfo(x)
47 for x in (locale.DAY_2, locale.DAY_3, locale.DAY_4,
48 locale.DAY_5, locale.DAY_6, locale.DAY_7, locale.DAY_1) ]
49 locale.setlocale(locale.LC_ALL, loc)
51 times = dict(enumerate('-------',1))
53 blocks = argument.split('|')
57 (th, tm) = time.split(':')
61 td = datetime.datetime(2000, 1, 1, int(th), int(tm), 0)
62 return '{:%H:%M}'.format(td)
65 (days, time) = b.split(';')
66 days = days.split(',')
67 (ts, te) = time.split('-')
68 t = tfmt(ts)+' - '+tfmt(te)
73 out += '''<table frame='all' xmlns="http://docbook.org/ns/docbook"
74 xmlns:xlink="http://www.w3.org/1999/xlink">
75 <title>'''+title[lang]+'''</title>
76 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
77 <colspec colname='day'/>
78 <colspec colname='time'/>
81 <entry align="center">'''+day_header[lang]+'''</entry>
82 <entry align="center">'''+time_header[lang]+'''</entry>
88 for day,t in zip(day_names,times.values()) :
93 </row>''' % (day.decode('utf-8'),t)
100 sys.stdout.write(out.encode('utf-8'))