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")
|
sys.stderr.write("\t" + e.__str__() + "\n")
|
||||||
return 1
|
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_preamble = "|URL|Network|Version|Location|Behind Cloudflare?|Comment|\n|-|-|-|-|-|-|\n"
|
||||||
table_rows = []
|
table_rows = []
|
||||||
for instance in instances["instances"]:
|
for instance in instances["instances"]:
|
||||||
@ -158,14 +145,24 @@ WARNING: This script will overwrite the output file if it exists.
|
|||||||
location = country
|
location = country
|
||||||
|
|
||||||
table_rows.append("|{0}|{1}|{2}|{3}|{4}|{5}|\n".format(
|
table_rows.append("|{0}|{1}|{2}|{3}|{4}|{5}|\n".format(
|
||||||
url,
|
url,
|
||||||
network,
|
network,
|
||||||
version,
|
version,
|
||||||
location,
|
location,
|
||||||
"\u2705" if cloudflare else "",
|
"\u2705" if cloudflare else "",
|
||||||
description
|
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)
|
out.write(table_preamble)
|
||||||
for row in table_rows:
|
for row in table_rows:
|
||||||
out.write(row)
|
out.write(row)
|
||||||
|
Loading…
Reference in New Issue
Block a user