Browse Source

error handling for showing genresult

master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
c122a88f64
  1. 9
      chunkymap-regen.py

9
chunkymap-regen.py

@ -68,18 +68,25 @@ def view_traceback():
def print_file(path, indent=""): def print_file(path, indent=""):
try: try:
if path is not None:
if os.path.isfile(path): if os.path.isfile(path):
line_count = 0
if indent is None: if indent is None:
indent = "" indent = ""
ins = open(path, 'r') ins = open(path, 'r')
line = True line = True
while line: while line:
line = ins.readline() line = ins.readline()
line_count += 1
if line: if line:
print(indent+line) print(indent+line)
ins.close() ins.close()
if line_count==0:
print(indent+"print_file WARNING: "+str(line_count)+" line(s) in '"+path+"'")
else: else:
print (indent+"print_file: missing path") print (indent+"print_file: file does not exist")
else:
print (indent+"print_file: path is None")
except: except:
print(indent+"print_file: could not finish") print(indent+"print_file: could not finish")

Loading…
Cancel
Save