Skip to content

Commit efc6a58

Browse files
ruff reformat
1 parent dee94d1 commit efc6a58

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

css-reports/app.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ async def fetch_customisation_report():
3434
print(f"Product Name: {product_name}")
3535

3636
if not auth_cookie or not organisation_id:
37-
return jsonify({"error": "An auth token and organisation id are required."}), 400
37+
return jsonify(
38+
{"error": "An auth token and organisation id are required."}
39+
), 400
3840

3941
if (not product_name) and (not product_names):
40-
return jsonify({"error": "Either product_name or product_names is required."}), 400
42+
return jsonify(
43+
{"error": "Either product_name or product_names is required."}
44+
), 400
4145

4246
if product_name and product_names:
43-
return jsonify({"error": "Both product_name and product_names cannot be provided."}), 400
47+
return jsonify(
48+
{"error": "Both product_name and product_names cannot be provided."}
49+
), 400
4450

4551
if not report_type:
4652
report_type = "Customisations"

css-reports/report.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,23 @@
1616
"Expires": "0",
1717
}
1818

19-
SALES_FROM_DATE_KEY: Final[str] = "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtFromDate"
20-
SALES_FROM_TIME_KEY: Final[str] = "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtFromTime"
21-
SALES_TO_DATE_KEY: Final[str] = "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtToDate"
22-
SALES_TO_TIME_KEY: Final[str] = "ctl00$ctl00$Main$AdminPageContent$drDateRange$txtToTime"
23-
24-
25-
async def get_msl_context(url: str, auth_cookie: str) -> tuple[dict[str, str], dict[str, str]]:
19+
SALES_FROM_DATE_KEY: Final[str] = (
20+
"ctl00$ctl00$Main$AdminPageContent$drDateRange$txtFromDate"
21+
)
22+
SALES_FROM_TIME_KEY: Final[str] = (
23+
"ctl00$ctl00$Main$AdminPageContent$drDateRange$txtFromTime"
24+
)
25+
SALES_TO_DATE_KEY: Final[str] = (
26+
"ctl00$ctl00$Main$AdminPageContent$drDateRange$txtToDate"
27+
)
28+
SALES_TO_TIME_KEY: Final[str] = (
29+
"ctl00$ctl00$Main$AdminPageContent$drDateRange$txtToTime"
30+
)
31+
32+
33+
async def get_msl_context(
34+
url: str, auth_cookie: str
35+
) -> tuple[dict[str, str], dict[str, str]]:
2636
"""Get the required context headers, data and cookies to make a request to MSL."""
2737

2838
BASE_COOKIES: Mapping[str, str] = {
@@ -70,8 +80,12 @@ async def fetch_report_url_and_cookies(
7080
report_type: str,
7181
) -> tuple[str | None, dict[str, str]]:
7282
"""Fetch the specified report from the guild website."""
73-
SALES_REPORTS_URL: Final[str] = f"https://www.guildofstudents.com/organisation/salesreports/{org_id}/"
74-
data_fields, cookies = await get_msl_context(url=SALES_REPORTS_URL, auth_cookie=auth_cookie)
83+
SALES_REPORTS_URL: Final[str] = (
84+
f"https://www.guildofstudents.com/organisation/salesreports/{org_id}/"
85+
)
86+
data_fields, cookies = await get_msl_context(
87+
url=SALES_REPORTS_URL, auth_cookie=auth_cookie
88+
)
7589

7690
form_data: dict[str, str] = {
7791
SALES_FROM_DATE_KEY: from_date.strftime("%d/%m/%Y"),
@@ -91,7 +105,10 @@ async def fetch_report_url_and_cookies(
91105
headers=BASE_HEADERS,
92106
cookies=cookies,
93107
)
94-
async with (session_v2, session_v2.post(url=SALES_REPORTS_URL, data=data_fields) as http_response,): # noqa: E501
108+
async with (
109+
session_v2,
110+
session_v2.post(url=SALES_REPORTS_URL, data=data_fields) as http_response,
111+
):
95112
if http_response.status != 200:
96113
print("Returned a non 200 status code!!")
97114
print(http_response)

0 commit comments

Comments
 (0)