Import signatures with wrong format
This commit is contained in:
parent
799c3a7f52
commit
cbe2dd8830
32 changed files with 121 additions and 46 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ _site
|
|||
.jekyll-cache
|
||||
.jekyll-metadata
|
||||
vendor
|
||||
__pycache__/
|
||||
|
|
2
_data/signed/Claverhouse.yaml
Normal file
2
_data/signed/Claverhouse.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Rupert Falcon Kavanagh ( Claverhouse )
|
||||
link: mailto:claverhouse@tutanota.de
|
2
_data/signed/Dench.yaml
Normal file
2
_data/signed/Dench.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Denis Avksentev
|
||||
link: https://dribbble.com/Dench
|
2
_data/signed/EchedeyLR.yaml
Normal file
2
_data/signed/EchedeyLR.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Echedey López Romero
|
||||
link: https://git.disroot.org/ELR
|
2
_data/signed/Invoker.yaml
Normal file
2
_data/signed/Invoker.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Kaced Sofiane
|
||||
link: mailto:kaced.sofiane@gmail.com
|
2
_data/signed/Jagadees.yaml
Normal file
2
_data/signed/Jagadees.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: jagadees, india.
|
||||
link: https://neritam.com
|
2
_data/signed/JoeSerpe.yaml
Normal file
2
_data/signed/JoeSerpe.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Joe Serpe
|
||||
link: https://simplemachines.it
|
2
_data/signed/JorwLNKwpH.yaml
Normal file
2
_data/signed/JorwLNKwpH.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: 郝歌
|
||||
link: https://blog.hiddenharmonies.org/
|
2
_data/signed/MikeSafonov.yaml
Normal file
2
_data/signed/MikeSafonov.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Mike Safonov
|
||||
link: https://github.com/MikeSafonov
|
2
_data/signed/MrClon.yaml
Normal file
2
_data/signed/MrClon.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: MrClon
|
||||
link: https://lor.sh/@MrClon
|
2
_data/signed/PetrB.yaml
Normal file
2
_data/signed/PetrB.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Petr Beliaev
|
||||
link: https://github.com/User330639
|
2
_data/signed/Princess-Luna-at.yaml
Normal file
2
_data/signed/Princess-Luna-at.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Dominic Westreicher
|
||||
link: mailto:d.westreicher@gmail.com
|
2
_data/signed/Suguivy.yaml
Normal file
2
_data/signed/Suguivy.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Nei S.
|
||||
link: https://nei.su
|
2
_data/signed/ewm.yaml
Normal file
2
_data/signed/ewm.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Eryk Michalak (ewm)
|
||||
link: https://ewm.codeberg.page/
|
2
_data/signed/hulten.yaml
Normal file
2
_data/signed/hulten.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Marco van Hulten (FSF associate member)
|
||||
link: http://marcovan.hulten.org/
|
2
_data/signed/if7.org.yaml
Normal file
2
_data/signed/if7.org.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: if7
|
||||
link: https://libreboot.org/
|
2
_data/signed/jakot.yaml
Normal file
2
_data/signed/jakot.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: jakot
|
||||
link: https://gitlab.com/jakot
|
2
_data/signed/jangid.yaml
Normal file
2
_data/signed/jangid.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Pankaj Jangid (Emacs Developer)
|
||||
link: https://codeisgreat.org/
|
2
_data/signed/jao.yaml
Normal file
2
_data/signed/jao.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Jose A Ortega Ruiz (FSF Associate Member, GNU MDK)
|
||||
link: https://codeberg.org/jao
|
2
_data/signed/krischik.yaml
Normal file
2
_data/signed/krischik.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Martin Krischik
|
||||
link: https://github.com/krischik
|
2
_data/signed/kriztolized.yaml
Normal file
2
_data/signed/kriztolized.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: kriztolized
|
||||
link: mailto:kriztolized@gmail.com
|
2
_data/signed/leonardfactory.yaml
Normal file
2
_data/signed/leonardfactory.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Leonardo Ascione
|
||||
link: https://github.com/leonardfactory
|
2
_data/signed/lospirit.yaml
Normal file
2
_data/signed/lospirit.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Evgeniy B.
|
||||
link: https://github.com/lospirit
|
2
_data/signed/manul.yaml
Normal file
2
_data/signed/manul.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Tinko Svrakov
|
||||
link: mailto:manul91@abv.bg
|
2
_data/signed/mcash.yaml
Normal file
2
_data/signed/mcash.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Matthew Cashman
|
||||
link: mailto:cashman@mit.edu
|
2
_data/signed/neilhaskins.yaml
Normal file
2
_data/signed/neilhaskins.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Neil Haskins
|
||||
link: https://neilhaskins.ca
|
2
_data/signed/nf.yaml
Normal file
2
_data/signed/nf.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Nathan Follens (GNOME Foundation member)
|
||||
link: https://l10n.gnome.org/users/nathan/
|
2
_data/signed/shtrih.yaml
Normal file
2
_data/signed/shtrih.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Dmitry M
|
||||
link: https://github.com/shtrih
|
2
_data/signed/sideus.yaml
Normal file
2
_data/signed/sideus.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Kyal Smith, South Africa
|
||||
link: mailto:kyal.smith@gmail.com
|
60
_importer.py
Normal file
60
_importer.py
Normal file
|
@ -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)
|
|
@ -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)
|
||||
|
|
|
@ -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…
Reference in a new issue