Browse Source

Import signatures with wrong format

pull/5631/head
Ivanq 1 year ago
parent
commit
cbe2dd8830
  1. 1
      .gitignore
  2. 2
      _data/signed/Claverhouse.yaml
  3. 2
      _data/signed/Dench.yaml
  4. 2
      _data/signed/EchedeyLR.yaml
  5. 2
      _data/signed/Invoker.yaml
  6. 2
      _data/signed/Jagadees.yaml
  7. 2
      _data/signed/JoeSerpe.yaml
  8. 2
      _data/signed/JorwLNKwpH.yaml
  9. 2
      _data/signed/MikeSafonov.yaml
  10. 2
      _data/signed/MrClon.yaml
  11. 2
      _data/signed/PetrB.yaml
  12. 2
      _data/signed/Princess-Luna-at.yaml
  13. 2
      _data/signed/Suguivy.yaml
  14. 2
      _data/signed/ewm.yaml
  15. 2
      _data/signed/hulten.yaml
  16. 2
      _data/signed/if7.org.yaml
  17. 2
      _data/signed/jakot.yaml
  18. 2
      _data/signed/jangid.yaml
  19. 2
      _data/signed/jao.yaml
  20. 2
      _data/signed/krischik.yaml
  21. 2
      _data/signed/kriztolized.yaml
  22. 2
      _data/signed/leonardfactory.yaml
  23. 2
      _data/signed/lospirit.yaml
  24. 2
      _data/signed/manul.yaml
  25. 2
      _data/signed/mcash.yaml
  26. 2
      _data/signed/neilhaskins.yaml
  27. 2
      _data/signed/nf.yaml
  28. 2
      _data/signed/shtrih.yaml
  29. 2
      _data/signed/sideus.yaml
  30. 60
      _importer.py
  31. 25
      add-from-issue.py
  32. 25
      import-from-codeberg.py

1
.gitignore

@ -3,3 +3,4 @@ _site
.jekyll-cache
.jekyll-metadata
vendor
__pycache__/

2
_data/signed/Claverhouse.yaml

@ -0,0 +1,2 @@
name: Rupert Falcon Kavanagh ( Claverhouse )
link: mailto:claverhouse@tutanota.de

2
_data/signed/Dench.yaml

@ -0,0 +1,2 @@
name: Denis Avksentev
link: https://dribbble.com/Dench

2
_data/signed/EchedeyLR.yaml

@ -0,0 +1,2 @@
name: Echedey López Romero
link: https://git.disroot.org/ELR

2
_data/signed/Invoker.yaml

@ -0,0 +1,2 @@
name: Kaced Sofiane
link: mailto:kaced.sofiane@gmail.com

2
_data/signed/Jagadees.yaml

@ -0,0 +1,2 @@
name: jagadees, india.
link: https://neritam.com

2
_data/signed/JoeSerpe.yaml

@ -0,0 +1,2 @@
name: Joe Serpe
link: https://simplemachines.it

2
_data/signed/JorwLNKwpH.yaml

@ -0,0 +1,2 @@
name: 郝歌
link: https://blog.hiddenharmonies.org/

2
_data/signed/MikeSafonov.yaml

@ -0,0 +1,2 @@
name: Mike Safonov
link: https://github.com/MikeSafonov

2
_data/signed/MrClon.yaml

@ -0,0 +1,2 @@
name: MrClon
link: https://lor.sh/@MrClon

2
_data/signed/PetrB.yaml

@ -0,0 +1,2 @@
name: Petr Beliaev
link: https://github.com/User330639

2
_data/signed/Princess-Luna-at.yaml

@ -0,0 +1,2 @@
name: Dominic Westreicher
link: mailto:d.westreicher@gmail.com

2
_data/signed/Suguivy.yaml

@ -0,0 +1,2 @@
name: Nei S.
link: https://nei.su

2
_data/signed/ewm.yaml

@ -0,0 +1,2 @@
name: Eryk Michalak (ewm)
link: https://ewm.codeberg.page/

2
_data/signed/hulten.yaml

@ -0,0 +1,2 @@
name: Marco van Hulten (FSF associate member)
link: http://marcovan.hulten.org/

2
_data/signed/if7.org.yaml

@ -0,0 +1,2 @@
name: if7
link: https://libreboot.org/

2
_data/signed/jakot.yaml

@ -0,0 +1,2 @@
name: jakot
link: https://gitlab.com/jakot

2
_data/signed/jangid.yaml

@ -0,0 +1,2 @@
name: Pankaj Jangid (Emacs Developer)
link: https://codeisgreat.org/

2
_data/signed/jao.yaml

@ -0,0 +1,2 @@
name: Jose A Ortega Ruiz (FSF Associate Member, GNU MDK)
link: https://codeberg.org/jao

2
_data/signed/krischik.yaml

@ -0,0 +1,2 @@
name: Martin Krischik
link: https://github.com/krischik

2
_data/signed/kriztolized.yaml

@ -0,0 +1,2 @@
name: kriztolized
link: mailto:kriztolized@gmail.com

2
_data/signed/leonardfactory.yaml

@ -0,0 +1,2 @@
name: Leonardo Ascione
link: https://github.com/leonardfactory

2
_data/signed/lospirit.yaml

@ -0,0 +1,2 @@
name: Evgeniy B.
link: https://github.com/lospirit

2
_data/signed/manul.yaml

@ -0,0 +1,2 @@
name: Tinko Svrakov
link: mailto:manul91@abv.bg

2
_data/signed/mcash.yaml

@ -0,0 +1,2 @@
name: Matthew Cashman
link: mailto:cashman@mit.edu

2
_data/signed/neilhaskins.yaml

@ -0,0 +1,2 @@
name: Neil Haskins
link: https://neilhaskins.ca

2
_data/signed/nf.yaml

@ -0,0 +1,2 @@
name: Nathan Follens (GNOME Foundation member)
link: https://l10n.gnome.org/users/nathan/

2
_data/signed/shtrih.yaml

@ -0,0 +1,2 @@
name: Dmitry M
link: https://github.com/shtrih

2
_data/signed/sideus.yaml

@ -0,0 +1,2 @@
name: Kyal Smith, South Africa
link: mailto:kyal.smith@gmail.com

60
_importer.py

@ -0,0 +1,60 @@
import os
def save_signature(name, link, author):
with open(f"_data/signed/{author}.yaml", "w") as f:
f.write(f"name: {name.strip()}\nlink: {link.strip()}\n")
def parse_and_import_signature(content, author):
if os.path.isfile(f"_data/signed/{author}.yaml"):
return
content_lines = [line.strip() for line in content.replace("`", "").strip().split("\n") if line.strip()]
imported = False
for i in range(len(content_lines) - 1):
if content_lines[i].lower().startswith("name:") and content_lines[i + 1].lower().startswith("link:"):
save_signature(content_lines[i][5:], content_lines[i + 1][5:], author)
imported = True
# Apparently most people can't follow a two-line template, e.g. miss 'name:'
# or 'link:' or use 'site:' instead of 'link:' or use 'mailto:' instead of
# 'link: mailto:', etc., so we have to guess in what way their
# interpretation is wrong, and try to make the format at least somewhat
# correct.
if not imported and len(content_lines) == 2:
name, link = content_lines
if name.lower().startswith("name:"):
name = name[5:]
if link.lower().startswith("link:"):
link = link[5:]
elif link.lower().startswith("site:"):
link = link[5:]
elif link.lower().startswith("mail:"):
link = "mailto:" + link[5:].strip()
elif link.lower().startswith("email:"):
link = "mailto:" + link[6:].strip()
elif link.lower().startswith("mailto:"):
link = "mailto:" + link[7:].strip()
# Demangle email
if "@" in link or "(at)" in link or "[at]" in link:
link = link.replace("[at]", "@")
link = link.replace("(at)", "@")
link = link.replace(" at ", "@")
link = link.replace("[dot]", ".")
link = link.replace("(dot)", ".")
link = link.replace(" dot ", ".")
link = link.replace(" ", "")
# Add protocol to links without it
if "@" in link:
if not link.startswith("mailto:"):
link = f"mailto:{link}"
elif link.startswith("www.") or link.endswith(".com"):
link = f"https://{link}"
if "/" in link or "@" in link:
save_signature(name, link, author)

25
add-from-issue.py

@ -1,5 +1,5 @@
import subprocess
import os
from _importer import parse_and_import_signature
parts = subprocess.run(["gh", "issue", "view", "837", "-c"], capture_output=True).stdout.split(b"\n--\n")
@ -11,25 +11,4 @@ for info, content in zip(parts[::2], parts[1::2]):
info_dict[key] = value
author = info_dict["author"]
content_lines = [line.strip() for line in content.decode().replace("`", "").strip().split("\n") if line.strip()]
imported = False
for i in range(len(content_lines) - 1):
if content_lines[i].lower().startswith("name:") and content_lines[i + 1].lower().startswith("link:"):
if not os.path.isfile(f"_data/signed/{author}.yaml"):
with open(f"_data/signed/{author}.yaml", "w") as f:
f.write("name:" + content_lines[i][5:] + "\nlink:" + content_lines[i + 1][5:] + "\n")
imported = True
if not imported and len(content_lines) == 2:
name, link = content_lines
if name.lower().startswith("name:"):
name = name[5:]
name = name.strip()
if link.lower().startswith("link:"):
link = link[5:]
link = link.strip()
if "/" in link or "@" in link:
if not os.path.isfile(f"_data/signed/{author}.yaml"):
with open(f"_data/signed/{author}.yaml", "w") as f:
f.write(f"name: {name}\nlink: {link}\n")
parse_and_import_signature(content.decode(), author)

25
import-from-codeberg.py

@ -1,5 +1,5 @@
import requests
import os
from _importer import parse_and_import_signature
page = 1
@ -10,26 +10,5 @@ while True:
for comment in comments:
author = comment["user"]["login"]
content = comment["body"]
content_lines = [line.strip() for line in content.replace("`", "").strip().split("\n") if line.strip()]
imported = False
for i in range(len(content_lines) - 1):
if content_lines[i].lower().startswith("name:") and content_lines[i + 1].lower().startswith("link:"):
if not os.path.isfile(f"_data/signed/{author}.yaml"):
with open(f"_data/signed/{author}.yaml", "w") as f:
f.write("name:" + content_lines[i][5:] + "\nlink:" + content_lines[i + 1][5:] + "\n")
imported = True
if not imported and len(content_lines) == 2:
name, link = content_lines
if name.lower().startswith("name:"):
name = name[5:]
name = name.strip()
if link.lower().startswith("link:"):
link = link[5:]
link = link.strip()
if "/" in link or "@" in link:
if not os.path.isfile(f"_data/signed/{author}.yaml"):
with open(f"_data/signed/{author}.yaml", "w") as f:
f.write(f"name: {name}\nlink: {link}\n")
parse_and_import_signature(content, author)
page += 1

Loading…
Cancel
Save