Skip to content

Commit

Permalink
Add some more advices to check-signatures-format.py
Browse files Browse the repository at this point in the history
  • Loading branch information
purplesyringa committed Mar 30, 2021
1 parent ccaa517 commit c1d3276
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions check-signatures-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def report(arg):
if contents.endswith("\n\n\n"):
report(f"{file_name} contains too many trailing empty lines. Please remove them.")

existing_keys = set()
existing_keys = {}
for i, line in enumerate(contents.split("\n")):
if not line:
continue
Expand Down Expand Up @@ -74,15 +74,19 @@ def report(arg):
report(f"{file_name} contains an empty '{key}:' on line {i + 1}, please fix this.")
continue

if key in existing_keys:
if key.lower() in existing_keys:
report(f"{file_name} contains duplicate key '{key}'.")
existing_keys.add(key.lower())
existing_keys[key.lower()] = i

if key == "name":
if any(c.strip() == "" and c != " " for c in value):
report(f"{file_name} contains an unexpected special whitespace character on line {i + 1}. Please replace it with a space.")
if len(" ".join(value.split())) < len(value):
report(f"{file_name} contains double space on line {i + 1}. Please keep a single space.")
if ": " in value and (value[0] != "\"" or value[-1] != "\""):
report(f"{file_name} contains a colon followed by a space (': ') in the name on line {i + 1}. This will cause the parser to parse the file incorrectly. Please wrap the name in double quotes.")
elif value.replace(" ", "").startswith("name"):
report(f"The name in {file_name} starts with 'name' on line {i + 1}. This may indicate a placeholder.")
elif key == "link":
if any(c.strip() == "" for c in value):
report(f"{file_name} contains unexpected whitespace on line {i + 1}. Please remove whitespace from the link.")
Expand All @@ -106,6 +110,8 @@ def report(arg):
report(f"{file_name} doesn't contain a name. Please specify your name or your alias.")
if "link" not in existing_keys:
report(f"{file_name} doesn't contain a link. Please specify a link to your online profile, e.g. on GitHub. If you really don't have a link, use /#")
if existing_keys["name"] != 0 or existing_keys["link"] != 1:
report(f"{file_name} incorrectly orders name and link. Please put the name on the first line and the link on the second line.")


if not ok:
Expand Down

0 comments on commit c1d3276

Please sign in to comment.