aboutsummaryrefslogtreecommitdiff
path: root/src/export.py
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2025-09-28 20:26:15 +0200
committerRodrigo <rodarima@gmail.com>2025-09-28 23:10:55 +0200
commitfb510ea86be5ceb9e91573890242581fdbd77ad8 (patch)
treed819fe40683592008d136727f5a0b03e48dc1164 /src/export.py
Initial versionHEADmain
Diffstat (limited to 'src/export.py')
-rw-r--r--src/export.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/export.py b/src/export.py
new file mode 100644
index 0000000..b453bc4
--- /dev/null
+++ b/src/export.py
@@ -0,0 +1,44 @@
+from github import Github
+from github import Auth
+import os
+
+token = None
+with open(os.path.expanduser('~') + "/.config/github/token", "r") as f:
+ token = str(f.readline().strip())
+
+auth = Auth.Token(token)
+
+g = Github(auth=auth)
+
+root = "."
+datefmt = '%a, %d %b %Y %H:%M:%S %z'
+
+repo = g.get_repo("dillo-browser/dillo")
+open_issues = repo.get_issues(state="all")
+for issue in open_issues:
+ print(issue)
+ n = issue.number
+ title = issue.title
+ body = issue.body
+ os.makedirs("%s/%d" % (root, n), exist_ok=True)
+ issue_file = "%s/%d/index.md" % (root, n)
+ if body is None:
+ body = ''
+
+ body = body.replace('\r\n', '\n')
+
+ with open(issue_file, "w") as f:
+ f.write("Title: " + issue.title + '\n')
+ f.write("Author: " + issue.user.login + '\n')
+ f.write("Created: " + issue.created_at.strftime(datefmt) + '\n')
+ f.write("State: " + issue.state + '\n')
+ f.write('\n')
+ f.write(body)
+ for comment in issue.get_comments():
+ f.write('\n\n--%--\n')
+ f.write('From: ' + comment.user.login + '\n')
+ f.write('Date: ' + comment.created_at.strftime(datefmt) + '\n')
+ f.write('\n')
+ f.write(comment.body.replace('\r\n', '\n'))
+
+g.close()