diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2024-06-02 21:56:41 +0200 |
---|---|---|
committer | Bryan Gardiner <bog@khumba.net> | 2024-07-19 20:30:20 -0700 |
commit | 5726997b396539f515a789b229a876c9b9503775 (patch) | |
tree | a2657740c5f5e450980ae02ac92d7f4a837d3994 /import_issues.py | |
parent | 32759f3bc1f2b806460a9713d99bfd375f263435 (diff) | |
download | lazygl2srht-5726997b396539f515a789b229a876c9b9503775.tar.gz |
refactor: simplify API signature
We don't need to concatenate srht_owner and srht_tracker again
and again, when we really need only complete tracker name.
Diffstat (limited to 'import_issues.py')
-rwxr-xr-x | import_issues.py | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/import_issues.py b/import_issues.py index e695b8a..642f9c6 100755 --- a/import_issues.py +++ b/import_issues.py @@ -237,8 +237,7 @@ def open_ticket( smtp, delay: float, mode: str, - srht_owner: str, - srht_tracker: str, + tracker: str, frm: str, title: str, body: str, @@ -285,7 +284,7 @@ def open_ticket( delay=delay, mode=mode, frm=frm, - to=f"~{srht_owner}/{srht_tracker}@todo.sr.ht", + to=f"{tracker}@todo.sr.ht", subject=title, body="\n".join(lines), ) @@ -299,8 +298,7 @@ def file_missing_ticket( smtp, delay: float, mode: str, - srht_owner: str, - srht_tracker: str, + tracker: str, frm: str, issue_id: int, ): @@ -311,7 +309,7 @@ def file_missing_ticket( delay=delay, mode=mode, frm=frm, - to=f"~{srht_owner}/{srht_tracker}@todo.sr.ht", + to=f"{tracker}@todo.sr.ht", subject="Missing issue", body=f"Issue {issue_id} is not known.", ) @@ -324,8 +322,7 @@ def file_missing_ticket( smtp=smtp, delay=delay, mode=mode, - srht_owner=srht_owner, - srht_tracker=srht_tracker, + tracker=tracker, frm=frm, issue_id=issue_count, closed_at=None, @@ -338,8 +335,7 @@ def send_comment( smtp, delay: float, mode: str, - srht_owner: str, - srht_tracker: str, + tracker: str, frm: str, issue_id: int, body: str, @@ -378,7 +374,7 @@ def send_comment( delay=delay, mode=mode, frm=frm, - to=f"~{srht_owner}/{srht_tracker}/{issue_id}@todo.sr.ht", + to=f"{tracker}/{issue_id}@todo.sr.ht", body="\n".join(lines), ) @@ -388,8 +384,7 @@ def close_ticket( smtp, delay: float, mode: str, - srht_owner: str, - srht_tracker: str, + tracker: str, frm: str, issue_id: int, closed_at: Optional[str], @@ -411,7 +406,7 @@ def close_ticket( delay=delay, mode=mode, frm=frm, - to=f"~{srht_owner}/{srht_tracker}/{issue_id}@todo.sr.ht", + to=f"{tracker}/{issue_id}@todo.sr.ht", body="\n".join(lines), ) @@ -421,8 +416,7 @@ def run( smtp, delay: float, mode: str, - srht_owner: str, - srht_tracker: str, + tracker: str, frm: str, export_dir_path: Path, gitlab_project_url: str, @@ -525,8 +519,7 @@ def run( smtp=smtp, delay=delay, mode=mode, - srht_owner=srht_owner, - srht_tracker=srht_tracker, + tracker=tracker, frm=frm, issue_id=gitlab_issue_id, ) @@ -557,8 +550,7 @@ def run( smtp=smtp, delay=delay, mode=mode, - srht_owner=srht_owner, - srht_tracker=srht_tracker, + tracker=tracker, frm=frm, title=issue_json["title"], body=issue_json["description"], @@ -626,8 +618,7 @@ def run( smtp=smtp, delay=delay, mode=mode, - srht_owner=srht_owner, - srht_tracker=srht_tracker, + tracker=tracker, frm=frm, issue_id=issue_id_map[issue_json["iid"]], body=body, @@ -646,8 +637,7 @@ def run( smtp=smtp, delay=delay, mode=mode, - srht_owner=srht_owner, - srht_tracker=srht_tracker, + tracker=tracker, frm=frm, issue_id=issue_id_map[issue_json["iid"]], closed_at=issue_json["closed_at"], @@ -830,6 +820,10 @@ def main(): include_confidential and skip_confidential ), f"Can accept at most one of --include-confidential and --skip-confidential." + srht_owner = args["srht_owner"] + srht_tracker = args["srht_tracker"] + tracker = f"~{srht_owner}/{srht_tracker}" + if mode == "print": smtp = None elif mode == "send": @@ -865,8 +859,7 @@ def main(): smtp=smtp, delay=float(args["delay"]), mode=mode, - srht_owner=args["srht_owner"], - srht_tracker=args["srht_tracker"], + tracker=tracker, frm=frm, export_dir_path=export_dir_path, gitlab_project_url=args["gitlab_project_url"].rstrip("/"), |