mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 15:26:30 +03:00
use P_DOMAIN_NAME instead of P_123 to make a diff easier, make sure, domains are lowercase
This commit is contained in:
@@ -7,7 +7,6 @@ import yaml
|
|||||||
|
|
||||||
out_all = ""
|
out_all = ""
|
||||||
out_domains = ""
|
out_domains = ""
|
||||||
count = 1
|
|
||||||
|
|
||||||
|
|
||||||
def cleanstr(s):
|
def cleanstr(s):
|
||||||
@@ -18,17 +17,23 @@ def cleanstr(s):
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
def file2varname(f):
|
||||||
|
f = f[f.rindex("/")+1:].replace(".md", "")
|
||||||
|
f = f.replace(".", "_")
|
||||||
|
f = f.replace("-", "_")
|
||||||
|
return "P_" + f.upper()
|
||||||
|
|
||||||
|
|
||||||
def file2url(f):
|
def file2url(f):
|
||||||
f = f[f.rindex("/")+1:]
|
f = f[f.rindex("/")+1:].replace(".md", "")
|
||||||
f = f.replace(".md", "")
|
|
||||||
f = f.replace(".", "-")
|
f = f.replace(".", "-")
|
||||||
return "https://providers.delta.chat/" + f
|
return "https://providers.delta.chat/" + f
|
||||||
|
|
||||||
|
|
||||||
def process_data(data, file):
|
def process_data(data, file):
|
||||||
global out_all, out_domains, count
|
global out_all, out_domains
|
||||||
status = data.get("status", "")
|
status = data.get("status", "")
|
||||||
out_provider = " static ref P" + str(count) + ": Provider = Provider {\n"
|
out_provider = " static ref " + file2varname(file) + ": Provider = Provider {\n"
|
||||||
if status == "OK" or status == "PREPARATION" or status == "BROKEN":
|
if status == "OK" or status == "PREPARATION" or status == "BROKEN":
|
||||||
out_provider += " status: Status::" + status + ",\n"
|
out_provider += " status: Status::" + status + ",\n"
|
||||||
else:
|
else:
|
||||||
@@ -39,9 +44,9 @@ def process_data(data, file):
|
|||||||
raise TypeError("no domains found")
|
raise TypeError("no domains found")
|
||||||
for domain in data["domains"]:
|
for domain in data["domains"]:
|
||||||
domain = cleanstr(domain)
|
domain = cleanstr(domain)
|
||||||
if domain == "" or domain.count(".") < 1:
|
if domain == "" or domain.count(".") < 1 or domain.lower() != domain:
|
||||||
raise TypeError("bad domain: " + domain)
|
raise TypeError("bad domain: " + domain)
|
||||||
out_domains += " (\"" + domain + "\", &*P" + str(count) + "),\n"
|
out_domains += " (\"" + domain + "\", &*" + file2varname(file) + "),\n"
|
||||||
comment += domain + ", "
|
comment += domain + ", "
|
||||||
|
|
||||||
out_server = ""
|
out_server = ""
|
||||||
@@ -86,14 +91,12 @@ def process_data(data, file):
|
|||||||
|
|
||||||
|
|
||||||
def process_file(file):
|
def process_file(file):
|
||||||
global count
|
|
||||||
print("processing file: " + file, file=sys.stderr)
|
print("processing file: " + file, file=sys.stderr)
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
# load_all() loads "---"-separated yamls -
|
# load_all() loads "---"-separated yamls -
|
||||||
# by coincidence, this is also the frontmatter separator :)
|
# by coincidence, this is also the frontmatter separator :)
|
||||||
data = next(yaml.load_all(f, Loader=yaml.SafeLoader))
|
data = next(yaml.load_all(f, Loader=yaml.SafeLoader))
|
||||||
process_data(data, file)
|
process_data(data, file)
|
||||||
count += 1
|
|
||||||
|
|
||||||
|
|
||||||
def process_dir(dir):
|
def process_dir(dir):
|
||||||
|
|||||||
Reference in New Issue
Block a user