first
This commit is contained in:
124
jira.py
Normal file
124
jira.py
Normal file
@@ -0,0 +1,124 @@
|
||||
import csv
|
||||
import re
|
||||
import os
|
||||
import json
|
||||
|
||||
# issues
|
||||
|
||||
f = open("issues.csv")
|
||||
|
||||
|
||||
reader = csv.reader(f)
|
||||
|
||||
|
||||
next(reader)
|
||||
|
||||
|
||||
for row in reader:
|
||||
id = row[0]
|
||||
assignee = row[1]
|
||||
creation_date = row[2]
|
||||
summary = row[-2]
|
||||
status = row[-3]
|
||||
issue_id = row[3]
|
||||
|
||||
if not re.match("^[A-Za-z\\-0-9]+$", issue_id):
|
||||
print("Invalid issue ID:", issue_id)
|
||||
break
|
||||
|
||||
# print(issue_id, assignee, creation_date, summary, status)
|
||||
|
||||
|
||||
o = open("md/" + issue_id + ".md", "w")
|
||||
|
||||
o.write("# " + summary + "\n\n")
|
||||
|
||||
o.write("| ID | Creation Date | Assignee | Status |\n")
|
||||
o.write("|----|----------------|----------|--------|\n")
|
||||
o.write(f"| {issue_id} | {creation_date} | {assignee} | {status} |\n")
|
||||
o.write("\n\n---\n\n")
|
||||
|
||||
|
||||
# issue body
|
||||
|
||||
|
||||
jsonfile = open(os.path.join("issues", issue_id + ".json"))
|
||||
data = json.loads(jsonfile.read())
|
||||
jsonfile.close()
|
||||
|
||||
o.write(data["fields"]["description"] or "No description" + "\n\n---\n\n")
|
||||
|
||||
o.close()
|
||||
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
# comments
|
||||
|
||||
|
||||
f = open("comments.csv")
|
||||
|
||||
reader = csv.reader(f)
|
||||
|
||||
|
||||
next(reader)
|
||||
|
||||
for row in reader:
|
||||
created_date = row[1]
|
||||
author = row[2]
|
||||
body = row[3]
|
||||
issue_id = row[4]
|
||||
|
||||
if not re.match("^[A-Za-z\\-0-9]+$", issue_id):
|
||||
print("Invalid issue ID:", issue_id)
|
||||
break
|
||||
|
||||
# print(issue_id, created_date, author, body)
|
||||
|
||||
o = open("md/" + issue_id + ".md", "a")
|
||||
|
||||
o.write(f"**{author}** commented on *{created_date}*:\n\n")
|
||||
o.write(f"{body}\n\n")
|
||||
o.write("\n\n---\n\n")
|
||||
|
||||
o.close()
|
||||
|
||||
f.close()
|
||||
|
||||
|
||||
for filename in os.listdir("issues"):
|
||||
if not re.match("^[0-9A-Za-z\\-]+\\.json$", filename):
|
||||
continue
|
||||
|
||||
f = open(os.path.join("issues", filename))
|
||||
data = json.loads(f.read())
|
||||
f.close()
|
||||
|
||||
o = open("md/" + filename[:-5] + ".md", "a")
|
||||
|
||||
o.write("\n\n## Attachments\n\n")
|
||||
|
||||
for a in data["fields"]["attachment"]:
|
||||
attachment_id = a["id"]
|
||||
|
||||
files = os.listdir(os.path.join("attachment", attachment_id))
|
||||
if len(files) == 0:
|
||||
print("No files for attachment ID:", attachment_id)
|
||||
continue
|
||||
|
||||
attachment_name = files[0]
|
||||
|
||||
if not re.match("^[0-9]+$", attachment_id):
|
||||
print("Invalid attachment ID:", attachment_id)
|
||||
continue
|
||||
|
||||
o.write("**" + attachment_id + "/" + attachment_name + "**")
|
||||
o.write("")
|
||||
o.write("\n\n---\n\n")
|
||||
|
||||
|
||||
o.close()
|
||||
|
||||
print(filename)
|
||||
|
||||
Reference in New Issue
Block a user