]>
code.delx.au - webdl/blob - grabber.py
3 from common
import load_root_node
, natural_sort
6 def choose(options
, allow_multi
):
8 for i
, (key
, value
) in enumerate(options
):
9 print "%3d) %s" % (i
+1, key
)
10 reverse_map
[i
+1] = value
14 values
= map(int, raw_input("Choose> ").split())
19 values
= [reverse_map
[value
] for value
in values
if value
in reverse_map
]
25 except (ValueError, IndexError):
26 print >>sys
.stderr
, "Invalid input, please try again"
30 node
= load_root_node()
35 for n
in node
.get_children():
36 options
.append((n
.title
, n
))
37 if not n
.can_download
:
39 options
= natural_sort(options
, key
=lambda x
: x
[0])
40 result
= choose(options
, allow_multi
=will_download
)
42 if node
.parent
is not None:
49 raw_input("Press return to continue...\n")
53 if __name__
== "__main__":
56 except (KeyboardInterrupt, EOFError):