]>
code.delx.au - webdl/blob - grabber.py
3 from common
import load_root_node
, natural_sort
5 # Python2 compatibility
12 def choose(options
, allow_multi
):
14 for i
, (key
, value
) in enumerate(options
):
15 print("%3d) %s" % (i
+1, key
))
16 reverse_map
[i
+1] = value
20 values
= list(map(int, raw_input("Choose> ").split()))
25 values
= [reverse_map
[value
] for value
in values
if value
in reverse_map
]
31 except (ValueError, IndexError):
32 print("Invalid input, please try again")
36 node
= load_root_node()
41 for n
in node
.get_children():
42 options
.append((n
.title
, n
))
43 if not n
.can_download
:
45 options
= natural_sort(options
, key
=lambda x
: x
[0])
46 result
= choose(options
, allow_multi
=will_download
)
48 if node
.parent
is not None:
55 raw_input("Press return to continue...\n")
59 if __name__
== "__main__":
62 except (KeyboardInterrupt, EOFError):