mirror of
https://github.com/redlib-org/redlib-instances.git
synced 2024-11-13 18:06:15 -05:00
Wait until after generating markdown before opening output file.
This commit is contained in:
parent
3bcf104307
commit
14c95045ba
@ -97,19 +97,6 @@ WARNING: This script will overwrite the output file if it exists.
|
||||
sys.stderr.write("\t" + e.__str__() + "\n")
|
||||
return 1
|
||||
|
||||
if parsed_args.OUTPUT_FILE == "-":
|
||||
out = sys.stdout
|
||||
else:
|
||||
try:
|
||||
mode="x"
|
||||
if os.path.exists(parsed_args.OUTPUT_FILE):
|
||||
mode="w"
|
||||
out = open(parsed_args.OUTPUT_FILE, mode)
|
||||
except Exception as e:
|
||||
sys.stderr.write("Error opening '{}' for writing:\n".format(parsed_args.OUTPUT_FILE))
|
||||
sys.stderr.write("\t" + e.__str__() + "\n")
|
||||
return 1
|
||||
|
||||
table_preamble = "|URL|Network|Version|Location|Behind Cloudflare?|Comment|\n|-|-|-|-|-|-|\n"
|
||||
table_rows = []
|
||||
for instance in instances["instances"]:
|
||||
@ -166,6 +153,16 @@ WARNING: This script will overwrite the output file if it exists.
|
||||
description
|
||||
))
|
||||
|
||||
if parsed_args.OUTPUT_FILE == "-":
|
||||
out = sys.stdout
|
||||
else:
|
||||
try:
|
||||
out = open(parsed_args.OUTPUT_FILE, "w" if os.path.exists(parsed_args.OUTPUT_FILE) else "x")
|
||||
except Exception as e:
|
||||
sys.stderr.write("Error opening '{}' for writing:\n".format(parsed_args.OUTPUT_FILE))
|
||||
sys.stderr.write("\t" + e.__str__() + "\n")
|
||||
return 1
|
||||
|
||||
out.write(table_preamble)
|
||||
for row in table_rows:
|
||||
out.write(row)
|
||||
|
Loading…
Reference in New Issue
Block a user