Working simple import script - unless issue title is too long

Then it breaks with:

Traceback (most recent call last):
  File '/home/mlncn/Projects/agaric/forgejo_helpers/import_issues.py', line 57, in <module>
    import_issues(owner, repo, csv_filename)
  File '/home/mlncn/Projects/agaric/forgejo_helpers/import_issues.py', line 47, in import_issues
    new_issue_url = json_response['html_url']
                    ~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'html_url'
This commit is contained in:
benjamin melançon 2024-05-15 17:25:23 -04:00
parent 24a99ee2d4
commit a3b0596584

View file

@ -21,13 +21,13 @@ def import_issues(owner, repo, csv_filename):
issues = [] issues = []
with open(csv_filename) as csvfile: with open(csv_filename) as csvfile:
rows = csv.reader(csvfile) rows = csv.reader(csvfile)
rows.pop(0)
for row in rows: for row in rows:
issues.append(row[0]) issues.append(row[0])
print(f"Creating issue {json_response['title']} now…") print(f"Creating issues now…")
issues.pop(0)
for issue in issues: for issue in issues:
new_issue = { new_issue = {
"title": issue "title": issue
@ -52,6 +52,6 @@ if __name__=="__main__":
# '0' comes in as move_issue.py when this is called as `python move_issue.py` # '0' comes in as move_issue.py when this is called as `python move_issue.py`
owner = sys.argv[1] owner = sys.argv[1]
repo = sys.argv[2] repo = sys.argv[2]
csv_filename = sys.argv[2] csv_filename = sys.argv[3]
import_issues(owner, repo, csvfile) import_issues(owner, repo, csv_filename)