summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xdownloader.py7
-rwxr-xr-xoutput.py23
3 files changed, 27 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index bee8a64b7..5cae28892 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 __pycache__
+issues
diff --git a/downloader.py b/downloader.py
index 5eec7346e..2b73f1cf5 100755
--- a/downloader.py
+++ b/downloader.py
@@ -1,6 +1,6 @@
 from requests import get
-from tomlkit import dumps
 from description_parser import parse_description
+from output import output_issue
 
 project_id = 11167699
 per_page = 100
@@ -30,10 +30,9 @@ def main():
                 "labels": i['labels'],
                 "url": i['web_url']
             }
-            issue = issue | parse_description(i['description'])
 
-            toml_string = dumps(issue)
-            print(toml_string)
+            issue = issue | parse_description(i['description'])
+            output_issue(issue)
 
 if __name__ == "__main__":
     main()
diff --git a/output.py b/output.py
new file mode 100755
index 000000000..745081aef
--- /dev/null
+++ b/output.py
@@ -0,0 +1,23 @@
+from tomlkit import dumps
+from os import path, makedirs
+
+def find_label(labels, keyword):
+    match = next((s for s in labels if f"{keyword}:" in s), None)
+    if not match:
+        return f"{keyword}_missing"
+    return match.replace(": ", "_")
+
+def write_file(file_path, string):
+    makedirs(path.dirname(file_path), exist_ok=True)
+    with open(file_path, "w") as file:
+        file.write(string)
+
+def output_issue(issue):
+    labels = issue['labels']
+    issue_id = issue['id']
+    toml_string = dumps(issue)
+
+    target_label = find_label(labels, "target")
+    host_label = find_label(labels, "host")
+    accel_label = find_label(labels, "accel")
+    write_file(f"issues/{target_label}/{host_label}/{accel_label}/{issue_id}.toml", toml_string)