3 import pprint
as pprint
6 """Loads a list of strings from file. Will append to given list
9 filename = os.path.expanduser (filename)
10 if not os.path.exists (filename):
11 print "Error: file '%s' does not exist."%(filename)
12 raise RuntimeError(
"Bad filename")
13 source = open (filename,
'r')
14 for line
in source.readlines():
15 line = re.sub (
r'#.+$',
'', line)
24 """Returns the appropriate sublist given the current section
27 size = len (inputList)
28 perSection = size // numSections
29 extra = size % numSections
30 start = perSection * currentSection
32 if currentSection < extra:
34 start += currentSection
39 return inputList[ start:stop ]
49 if __name__ ==
"__main__":
56 historyPath = os.path.expanduser(
"~/.pyhistory")
61 readline.write_history_file(historyPath)
62 if os.path.exists(historyPath):
63 readline.read_history_file(historyPath)
66 atexit.register(save_history)
67 readline.parse_and_bind(
"set show-all-if-ambiguous on")
68 readline.parse_and_bind(
"tab: complete")
69 if os.path.exists (historyPath) :
70 readline.read_history_file(historyPath)
71 readline.set_history_length(-1)