1
0

Compare commits

...

5 Commits

Author SHA1 Message Date
45233bd593 fix: Assign exception message to variable before raising ValueError
All checks were successful
Run Python tests (through Pytest) / Test (push) Successful in 36s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 31s
2025-04-08 22:55:24 +02:00
82cfd45878 style: Consistently use single quotes for string literals in code 2025-04-08 22:54:13 +02:00
f38923e8fb fix: Replace assert with ValueError for empty sample_filter check 2025-04-08 22:53:53 +02:00
b60b8c7416 style: Format code for improved readability and consistency 2025-04-08 22:52:29 +02:00
0e1779cca0 fix: Remove unnecessary del statements from __main__.py file 2025-04-08 22:51:31 +02:00
6 changed files with 14 additions and 10 deletions

View File

@ -19,7 +19,9 @@ def filter_samples(
samples: list[ActivitySample], samples: list[ActivitySample],
sample_filter: set[str], sample_filter: set[str],
) -> list[ActivitySample]: ) -> list[ActivitySample]:
assert len(sample_filter) > 0 if not sample_filter:
error_message = 'sample_filter must not be empty'
raise ValueError(error_message)
return [s for s in samples if set(s.labels).intersection(sample_filter)] return [s for s in samples if set(s.labels).intersection(sample_filter)]
@ -83,7 +85,6 @@ def load_samples(args) -> set[ActivitySample]:
shared_time_stamps_set |= set( shared_time_stamps_set |= set(
git_repo.iterate_samples_from_git_repository(repo_path), git_repo.iterate_samples_from_git_repository(repo_path),
) )
del repo_path
# CSV Files # CSV Files
for csv_path in args.csv_files: for csv_path in args.csv_files:
@ -91,7 +92,6 @@ def load_samples(args) -> set[ActivitySample]:
shared_time_stamps_set |= set( shared_time_stamps_set |= set(
csv_file.iterate_samples_from_csv_file(csv_path), csv_file.iterate_samples_from_csv_file(csv_path),
) )
del csv_path
return shared_time_stamps_set return shared_time_stamps_set

View File

@ -1,7 +1,6 @@
import datetime
import json
import logging import logging
from pathlib import Path from pathlib import Path
import bottle import bottle
from personal_data import csv_import from personal_data import csv_import
@ -19,7 +18,7 @@ def newest_entry(csv_type: str):
finds the newest entry based on the 'time.current' column, and returns it as JSON. finds the newest entry based on the 'time.current' column, and returns it as JSON.
""" """
path = ROOT_DIRECTORY/f'{csv_type}.csv' path = ROOT_DIRECTORY / f'{csv_type}.csv'
bottle.response.content_type = 'application/json' bottle.response.content_type = 'application/json'
@ -41,7 +40,10 @@ def newest_entry(csv_type: str):
else: else:
newest = data[-1] newest = data[-1]
return {csv_import.csv_safe_value(k):csv_import.csv_safe_value(v) for k,v in newest.items()} return {
csv_import.csv_safe_value(k): csv_import.csv_safe_value(v)
for k, v in newest.items()
}
if __name__ == '__main__': if __name__ == '__main__':

1
scripts/__init__.py Normal file
View File

@ -0,0 +1 @@
# This file marks the scripts directory as a package.

View File

@ -32,9 +32,9 @@ def parse_results(response) -> list[Result]:
link = cells[0].a link = cells[0].a
if link is None: if link is None:
continue continue
id = link['href'].removeprefix('viewsimfile.php?simfileid=') simfile_id = link['href'].removeprefix('viewsimfile.php?simfileid=')
levels = cells[1].get_text().strip() levels = cells[1].get_text().strip()
results.append(Result(title, int(id), levels)) results.append(Result(title, int(simfile_id), levels))
return results return results

1
tests/__init__.py Normal file
View File

@ -0,0 +1 @@
# This file marks the tests directory as a package.

View File

@ -4,7 +4,7 @@ from personal_data.fetchers.myanimelist import parse_name
@pytest.mark.parametrize( @pytest.mark.parametrize(
'input_str, expected_group1, expected_group2', ('input_str', 'expected_group1', 'expected_group2'),
[ [
('"Soundscape"', 'Soundscape', None), ('"Soundscape"', 'Soundscape', None),
('"Soundscape (サウンドスケープ)"', 'Soundscape', 'サウンドスケープ'), ('"Soundscape (サウンドスケープ)"', 'Soundscape', 'サウンドスケープ'),