Mercurial > hg > config
comparison python/html2flux.py @ 296:ee3c1b65d6d1
random fixes
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 11 May 2013 06:50:40 -0700 |
parents | a0d830fd8a42 |
children | a43d0205f80b |
comparison
equal
deleted
inserted
replaced
295:e2564dd51334 | 296:ee3c1b65d6d1 |
---|---|
23 | 23 |
24 # available executables | 24 # available executables |
25 executables = set([i.rsplit('/', 1)[-1] for i in lsex() ]) | 25 executables = set([i.rsplit('/', 1)[-1] for i in lsex() ]) |
26 | 26 |
27 def readmenu(dl, output, top=True): | 27 def readmenu(dl, output, top=True): |
28 """read menu from an <dl> tag""" | |
29 # TODO: probably don't really need lxml | |
28 | 30 |
29 menu_items = [] | 31 menu_items = [] |
30 name = None # menu name | 32 name = None # menu name |
31 firstchild = True | 33 firstchild = True |
32 label = None | 34 label = None |
55 | 57 |
56 def printflux(name, menu, output, top=True): | 58 def printflux(name, menu, output, top=True): |
57 """ | 59 """ |
58 - output: file-like object for writing | 60 - output: file-like object for writing |
59 """ | 61 """ |
62 | |
63 # print [submenu] tag for this menu | |
60 name = name or '' | 64 name = name or '' |
61 print >> output, '[submenu] (%s)' % name | 65 if not top: |
66 print >> output, '[submenu] (%s)' % name | |
67 | |
68 # print menu items | |
62 for name, item in menu: | 69 for name, item in menu: |
63 if isinstance(item, basestring): | 70 if isinstance(item, basestring): |
64 # command | 71 # command |
65 print >> output, '[exec] (%s) {%s}' % (name, item) | 72 print >> output, '[exec] (%s) {%s}' % (name, item) |
66 else: | 73 else: |
67 # submenu | 74 # submenu |
68 printflux(name, item, output, top=False) | 75 printflux(name, item, output, top=False) |
76 | |
77 # print end of this submenu | |
69 if not top: | 78 if not top: |
70 print >> output, '[end]' | 79 print >> output, '[end]' |
71 | 80 |
72 def printmenu(dl, output): | 81 def printmenu(dl, output): |
73 name, menu = readmenu(dl, output) | 82 name, menu = readmenu(dl, output) |