Skip to content

Commit f9c249e

Browse files
Fix some pylint bits
1 parent 9072208 commit f9c249e

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

css-reports/app.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
from flask import Flask, request, send_file, jsonify, redirect
2-
from report import get_product_customisations
1+
"""Module to handle the incoming http requests and generate reports."""
2+
33
from datetime import datetime
44
import os
55
import re
66

7+
from flask import Flask, request, send_file, jsonify, redirect
8+
from report import get_product_customisations
9+
10+
711
app = Flask("css-reports")
812

913

1014
@app.route("/")
1115
def hello():
16+
"""Redirect to the main website if no specific route is requested."""
1217
return redirect("https://cssbham.com", code=302)
1318

1419

1520
@app.errorhandler(404)
1621
def page_not_found(e: Exception | int):
22+
"""Handle 404 errors by redirecting to the main website."""
1723
print(e)
1824
return redirect("https://cssbham.com", code=302)
1925

2026

2127
@app.route("/customisation_report", methods=["GET"])
2228
async def fetch_customisation_report():
29+
"""Fetch the report based on query parameters."""
2330
# Retrieve query parameters
2431
auth_cookie: str | None = request.args.get("auth_cookie")
2532
organisation_id: str | None = request.args.get("organisation_id")

css-reports/report.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""Python script to fetch a customisation report from the Guild website."""
22

3+
import re
4+
from datetime import datetime
5+
36
from typing import Final, Mapping, TYPE_CHECKING
47
import aiohttp
58
import bs4
69
from bs4 import BeautifulSoup
7-
import re
8-
from datetime import datetime
10+
911

1012
if TYPE_CHECKING:
1113
from http.cookies import Morsel
@@ -70,7 +72,10 @@ async def fetch_report_url_and_cookies(
7072
report_type: str,
7173
) -> tuple[str | None, dict[str, str]]:
7274
"""Fetch the specified report from the guild website."""
73-
SALES_REPORTS_URL: Final[str] = f"https://www.guildofstudents.com/organisation/salesreports/{org_id}/"
75+
SALES_REPORTS_URL: Final[str] = (
76+
f"https://www.guildofstudents.com/organisation/salesreports/{org_id}/"
77+
)
78+
7479
data_fields, cookies = await get_msl_context(url=SALES_REPORTS_URL, auth_cookie=auth_cookie)
7580

7681
form_data: dict[str, str] = {
@@ -91,7 +96,10 @@ async def fetch_report_url_and_cookies(
9196
headers=BASE_HEADERS,
9297
cookies=cookies,
9398
)
94-
async with (session_v2, session_v2.post(url=SALES_REPORTS_URL, data=data_fields) as http_response): # noqa: E501
99+
async with (
100+
session_v2,
101+
session_v2.post(url=SALES_REPORTS_URL, data=data_fields) as http_response
102+
):
95103
if http_response.status != 200:
96104
print("Returned a non 200 status code!!")
97105
print(http_response)

0 commit comments

Comments
 (0)