Skip to content

Commit b7df37f

Browse files
authored
Merge pull request #84 from Zohair-coder/dev
Dev
2 parents 421ee9e + a264e96 commit b7df37f

File tree

9 files changed

+24
-15
lines changed

9 files changed

+24
-15
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
"vscode": {
1313
"extensions": [
1414
"ms-python.python",
15-
"ms-python.black-formatter"
16-
]
15+
"charliermarsh.ruff"
16+
],
17+
"settings": {
18+
"editor.defaultFormatter": "charliermarsh.ruff",
19+
"editor.formatOnSave": true
20+
}
1721
}
1822
}
1923
}

.github/workflows/functional_test.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v4
1313

14-
- name: Check code formatting with Black
15-
uses: psf/black@stable
14+
- name: Install Python
15+
uses: actions/setup-python@v5
1616
with:
17-
options: "--check --verbose"
18-
src: "./src"
17+
python-version: "3.11"
18+
19+
- name: Install linter/formatter dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install ruff
23+
24+
- name: Run Linter
25+
run: ruff check --output-format=github src
26+
27+
- name: Run Formatter
28+
run: ruff format --check src
1929

2030
- name: Set up Docker Compose
2131
uses: docker/setup-buildx-action@v3
@@ -87,7 +97,7 @@ jobs:
8797
fi
8898
8999
- name: Reset database
90-
run: docker compose run scraper sh -c 'apk add postgresql-client && ./reset_db.bash;'
100+
run: docker compose run scraper sh -c 'apk add postgresql-client && ./scripts/reset_db.sh;'
91101

92102
- name: Run scraper again (to test cache)
93103
run: docker compose run scraper python3 src/main.py --db --all-colleges --ratings

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ python src/main.py --db
9292
This will create a new database `schedulerdb` and the necessary tables if they aren't already created, and then insert the data into the database. If the data is already populated, it will update the existing data. To delete all the data, make sure the environment variables specified in `src/db_config.py` are set and then run the following command (make sure you're using the Git Bash terminal if you're using Windows):
9393

9494
```bash
95-
./reset_db.bash
95+
./scripts/reset_db.sh
9696
```
9797

9898
To view the schema for the tables, you can look at the `src/create_tables.sql` file.

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ services:
6666
- EDGE_PORT=4566
6767
volumes:
6868
- "/var/run/docker.sock:/var/run/docker.sock"
69-
- "./sns-init-scripts/create-sns-topic.sh:/etc/localstack/init/ready.d/init-aws.sh"
69+
- "./scripts/create-sns-topic.sh:/etc/localstack/init/ready.d/init-aws.sh"
File renamed without changes.

src/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def main(args: argparse.Namespace):
3636

3737

3838
if __name__ == "__main__":
39-
4039
parser = argparse.ArgumentParser(
4140
description="Scrape data from Term Master Schedule and save it to a data.json file."
4241
)
@@ -67,7 +66,7 @@ def main(args: argparse.Namespace):
6766
if not os.path.exists("performance"):
6867
os.makedirs("performance")
6968
cProfile.run("main(args)", "performance/profile_output.pstat")
70-
except Exception as e:
69+
except Exception:
7170
trace = traceback.format_exc()
7271
print(trace)
7372

src/parse.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
def parse_subject_page(
88
html, data: dict, include_ratings: bool = False, ratings_cache: dict = {}
99
):
10-
1110
soup = BeautifulSoup(html, "html.parser")
1211
table_rows = soup.find_all("tr", class_=["odd", "even"])
1312

@@ -82,7 +81,6 @@ def get_instructors(
8281
name = instructor.strip()
8382

8483
if include_ratings:
85-
8684
# Search for first word and last word in name first
8785
# If that doesn't work, try first two words
8886
# If that still doesn't work, don't include rating
@@ -142,7 +140,6 @@ def fix_encoding_issue(text: str) -> str:
142140

143141

144142
def parse_days(d: str):
145-
146143
if d == "TBD":
147144
return None
148145

src/scrape.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def scrape_all_subjects(session: Session, data: dict, html: str, include_ratings
6262
for subject_page_link in college_page_soup.find_all(
6363
"a", href=lambda href: href and href.startswith("/webtms_du/courseList")
6464
):
65-
6665
try:
6766
response = send_request(
6867
session, config.tms_base_url + subject_page_link["href"]

0 commit comments

Comments
 (0)