Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWoollett-Light committed Mar 19, 2024
1 parent 12c135f commit eeab6b5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,29 @@ def post(table):
session_cookie = login()

match data_text_opt, data_file_opt, repo_opt:
case None, None, None:
print(f"Neither `{DATA_TEXT}`, `{DATA_FILE}` or `{REPO}` set, skipping upload.")
case [None, None, _]:
raise ValueError(
f"if `{REPO}` is set, either `{DATA_TEXT}` or `{DATA_FILE}` must be set."
)
case [_, _, None]:
raise ValueError(
f"if `{DATA_TEXT}` or `{DATA_FILE}` is set, `{REPO}` must be set."
)
case None, data_file, repo:
with open(data_file, "r", encoding="utf-8") as file:
data_str = file.read()
print(f"data_str: {data_str}")
upload(head, data_str)
case data_text, None, repo:
upload(head, data_text)
case None, None, None:
print(f"Neither `{DATA_TEXT}`, `{DATA_FILE}` or `{REPO}` set, skipping upload.")
case data_text, data_file, _:
raise ValueError(
f"`{DATA_TEXT}` ({data_text}) and `{DATA_FILE}` ({data_file}) must not both be set."
)


BASE = "BASE"
ISSUE = "ISSUE"
TOKEN = "TOKEN"
Expand All @@ -245,12 +254,12 @@ def post(table):
print(f"token_opt: {token_opt}")

match base_opt, issue_opt, token_opt, repo_opt:
case base, issue, token, repo:
post(diff())
case None, None, None, _:
print(f"None of `{BASE}`, `{ISSUE}` or `{TOKEN}` set, skipping diff.")
case _:
case [_, _, None, _] | [_, None, _, _] | [None, _, _, _]:
raise ValueError(
f"`{BASE}` ({base_opt}), `{ISSUE}` ({issue_opt}) and `{TOKEN}` ({token_opt}) must all \
be set when any are set."
)
case base, issue, token, repo:
post(diff())

0 comments on commit eeab6b5

Please sign in to comment.