Skip to content

Commit 6d43ff4

Browse files
committed
chore: add makefile
1 parent 099e7d1 commit 6d43ff4

6 files changed

Lines changed: 72 additions & 48 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
__pycache__/
12
.mypy_cache/
23
.pytest_cache/
4+
.ruff_cache/
35
.venv/
4-
__pycache__/
56
bin/
67
out/
8+
tmp/
79
*.egg-info/
810
*.pyz

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
format:
2+
uv run ruff format
3+
uv run ruff check --select I --fix
4+
5+
lint:
6+
uv run ruff check
7+
8+
lint-fix:
9+
uv run ruff check --fix
10+
11+
test:
12+
uv run pytest

scripts/inventory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def append_record(data, file_path, files):
4040
filetype = "l"
4141
elif path.isdir(file):
4242
filetype = "d"
43-
mod_time = datetime.fromtimestamp(
44-
path.getmtime(file), tz=UTC
45-
).strftime("%Y-%m-%d-%H:%M")
43+
mod_time = datetime.fromtimestamp(path.getmtime(file), tz=UTC).strftime(
44+
"%Y-%m-%d-%H:%M"
45+
)
4646
else:
4747
stat = os.stat(file)
4848
filesize = stat.st_size

scripts/split.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ def clean_name(name: str) -> str:
1616
def run_ffprobe(file_path: Path):
1717
cmd = [
1818
"ffprobe",
19-
"-v", "error",
20-
"-print_format", "json",
19+
"-v",
20+
"error",
21+
"-print_format",
22+
"json",
2123
"-show_chapters",
22-
str(file_path)
24+
str(file_path),
2325
]
2426
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
2527
return json.loads(result.stdout)
@@ -29,26 +31,31 @@ def encode_chapter(input_file: Path, out_file: Path, start: float, duration: flo
2931
cmd = [
3032
"ffmpeg",
3133
"-hide_banner",
32-
"-loglevel", "error",
34+
"-loglevel",
35+
"error",
3336
"-y",
34-
35-
"-ss", str(start),
36-
"-i", str(input_file),
37-
"-t", str(duration),
38-
37+
"-ss",
38+
str(start),
39+
"-i",
40+
str(input_file),
41+
"-t",
42+
str(duration),
3943
# Only audio stream
40-
"-map", "0:a:0",
44+
"-map",
45+
"0:a:0",
4146
"-vn",
42-
43-
"-c:a", "libopus",
44-
"-b:a", BITRATE,
45-
"-vbr", "on",
46-
"-compression_level", "10",
47-
47+
"-c:a",
48+
"libopus",
49+
"-b:a",
50+
BITRATE,
51+
"-vbr",
52+
"on",
53+
"-compression_level",
54+
"10",
4855
# No broken metadata
49-
"-map_metadata", "-1",
50-
51-
str(out_file)
56+
"-map_metadata",
57+
"-1",
58+
str(out_file),
5259
]
5360

5461
subprocess.run(cmd, check=True)

tests/test_ical.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44

55
from scripts import ical
66

7-
DATA = {
8-
"Test": ["05.01.2021", "10.03.2021"]
9-
}
10-
11-
RESULT = ("BEGIN:VCALENDAR\n"
12-
"BEGIN:VEVENT\n"
13-
"SUMMARY:Test\n"
14-
"DTSTART;VALUE=DATE:20210105\n"
15-
"TRANSP:TRANSPARENT\n"
16-
"END:VEVENT\n"
17-
"BEGIN:VEVENT\n"
18-
"SUMMARY:Test\n"
19-
"DTSTART;VALUE=DATE:20210310\n"
20-
"TRANSP:TRANSPARENT\n"
21-
"END:VEVENT\n"
22-
"END:VCALENDAR")
7+
DATA = {"Test": ["05.01.2021", "10.03.2021"]}
8+
9+
RESULT = (
10+
"BEGIN:VCALENDAR\n"
11+
"BEGIN:VEVENT\n"
12+
"SUMMARY:Test\n"
13+
"DTSTART;VALUE=DATE:20210105\n"
14+
"TRANSP:TRANSPARENT\n"
15+
"END:VEVENT\n"
16+
"BEGIN:VEVENT\n"
17+
"SUMMARY:Test\n"
18+
"DTSTART;VALUE=DATE:20210310\n"
19+
"TRANSP:TRANSPARENT\n"
20+
"END:VEVENT\n"
21+
"END:VCALENDAR"
22+
)
2323

2424
TEST_PATH = "./out/test.ics"
2525

tests/test_shift.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
from scripts import shift
44

55

6-
@pytest.mark.parametrize(("message", "result"), [
7-
("Test", "Uftu"),
8-
("123", "234"),
9-
("Test 123", "Uftu 234"),
10-
("xyz", "yza"),
11-
("+#.", "+#."),
12-
("789", "890"),
13-
("ABCxyz-012789", "BCDyza-123890")
14-
])
6+
@pytest.mark.parametrize(
7+
("message", "result"),
8+
[
9+
("Test", "Uftu"),
10+
("123", "234"),
11+
("Test 123", "Uftu 234"),
12+
("xyz", "yza"),
13+
("+#.", "+#."),
14+
("789", "890"),
15+
("ABCxyz-012789", "BCDyza-123890"),
16+
],
17+
)
1518
def test_shift(message, result):
1619
assert shift.shift(message) == result

0 commit comments

Comments
 (0)