comparison python/html2flux.py @ 293:45b970048ae2

resurrect this ole beast
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 11 May 2013 03:24:47 -0700
parents fbc033540a34
children a0d830fd8a42
comparison
equal deleted inserted replaced
292:fbc033540a34 293:45b970048ae2
21 from lsex import lsex # local import 21 from lsex import lsex # local import
22 22
23 # available executables 23 # available executables
24 executables = set([i.rsplit('/', 1)[-1] for i in lsex() ]) 24 executables = set([i.rsplit('/', 1)[-1] for i in lsex() ])
25 25
26 def printmenu(dl, output, top=True): 26 def readmenu(dl, output, top=True):
27 27
28 menu_items = [] 28 menu_items = []
29 name = None # menu name 29 name = None # menu name
30 for child in dl.iterchildren(): 30 for child in dl.iterchildren():
31 31
45 if child.tag == 'dl': 45 if child.tag == 'dl':
46 printmenu(child, output, top=False) 46 printmenu(child, output, top=False)
47 if not top: 47 if not top:
48 print >> output, '[end]' 48 print >> output, '[end]'
49 49
50 def printmenu(dl, output):
51 """
52 - output: file-like object for writing
53 """
54 menu = readmenu(dl, output)
55
50 def main(args=sys.argv[1:]): 56 def main(args=sys.argv[1:]):
57 """command line interface"""
51 58
52 # parse command line option 59 # parse command line option
53 usage = '%prog [options] [menu.html]' 60 usage = '%prog [options] [menu.html]'
54 parser = optparse.OptionParser(usage=usage, 61 parser = optparse.OptionParser(usage=usage,
55 description=__doc__) 62 description=__doc__)