Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions package.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

import sys
import zipapp
from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies = [
[dependency-groups]
dev = [
"pytest==9.1.1",
"ruff==0.14.4",
"ruff==0.16.4",
]

[tool.ruff.lint]
Expand Down
12 changes: 5 additions & 7 deletions scripts/archiver.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env python3

import os
import shlex
import subprocess
import sys
from argparse import ArgumentParser, ArgumentTypeError, Namespace
from typing import Iterator
from collections.abc import Iterator

import common

Expand Down Expand Up @@ -41,9 +39,9 @@ def create_archives(

try:
completed_process.check_returncode()
except subprocess.CalledProcessError as ex:
except subprocess.CalledProcessError:
print(completed_process.stderr.decode(), file=sys.stderr)
raise ex
raise

stdout = completed_process.stdout.decode()

Expand All @@ -70,9 +68,9 @@ def test_archives(

try:
completed_process.check_returncode()
except subprocess.CalledProcessError as ex:
except subprocess.CalledProcessError:
print(completed_process.stderr.decode(), file=sys.stderr)
raise ex
raise

stdout = completed_process.stdout.decode()

Expand Down
4 changes: 1 addition & 3 deletions scripts/backupper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python3

import os
from argparse import ArgumentParser, ArgumentTypeError, Namespace
from typing import Iterator
from collections.abc import Iterator

import checksum
from archiver import Archiver
Expand Down
4 changes: 1 addition & 3 deletions scripts/checksum.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python3

import hashlib
import os
from argparse import ArgumentParser, Namespace
from typing import Iterator
from collections.abc import Iterator


def _create_argument_parser() -> ArgumentParser:
Expand Down
2 changes: 0 additions & 2 deletions scripts/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

import json
import logging
import os
Expand Down
7 changes: 3 additions & 4 deletions scripts/edx.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3

import os
from pathlib import Path
from typing import ClassVar

import requests
from markdownify import markdownify as md
Expand All @@ -19,7 +18,7 @@ class EdxCrawler:
course_name = "k8s"
email = "xxx"
password = "xxx"
headers = {
headers: ClassVar[dict[str, str]] = {
"User-Agent": (
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
Expand Down Expand Up @@ -70,7 +69,7 @@ def _get_content(self):
breadcrumb_elements = self.driver.find_elements(
By.XPATH, "//nav[@aria-label='breadcrumb']/ol/li"
)
breadcrumbs = list(map(lambda e: e.text, breadcrumb_elements))
breadcrumbs = [element.text for element in breadcrumb_elements]
section = " ".join(breadcrumbs[2:])
if self.current_section != section:
self.current_section = section
Expand Down
5 changes: 2 additions & 3 deletions scripts/enny_mo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python3

import re
from functools import partial
from pathlib import Path
from typing import ClassVar
from urllib.parse import urljoin

import scrapy
Expand All @@ -11,7 +10,7 @@


class EnnyMoSpider(scrapy.Spider):
headers = {
headers: ClassVar[dict[str, str]] = {
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) "
"Gecko/20100101 Firefox/77.0"
Expand Down
2 changes: 0 additions & 2 deletions scripts/feed_downloader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

import re
from pathlib import Path

Expand Down
7 changes: 4 additions & 3 deletions scripts/ical.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

from datetime import datetime
from pathlib import Path

Expand Down Expand Up @@ -45,7 +43,10 @@ def create_ical(data):
for event_date in data[event_name]:
event = Event()
event.add("summary", event_name)
event.add("dtstart", datetime.strptime(event_date, "%d.%m.%Y").date())
event.add(
"dtstart",
datetime.strptime(event_date, "%d.%m.%Y").date(), # noqa: DTZ007
)
event.add("transp", "TRANSPARENT")
cal.add_component(event)

Expand Down
14 changes: 7 additions & 7 deletions scripts/inventory.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python3

import argparse
import csv
import os
from datetime import datetime
from datetime import UTC, datetime
from os import path
from pathlib import Path

Expand Down Expand Up @@ -42,13 +40,15 @@ def append_record(data, file_path, files):
filetype = "l"
elif path.isdir(file):
filetype = "d"
mod_time = datetime.fromtimestamp(path.getmtime(file)).strftime(
"%Y-%m-%d-%H:%M"
)
mod_time = datetime.fromtimestamp(
path.getmtime(file), tz=UTC
).strftime("%Y-%m-%d-%H:%M")
else:
stat = os.stat(file)
filesize = stat.st_size
mod_time = datetime.fromtimestamp(stat.st_mtime).strftime("%Y-%m-%d-%H:%M")
mod_time = datetime.fromtimestamp(stat.st_mtime, tz=UTC).strftime(
"%Y-%m-%d-%H:%M"
)
data.append([file, filetype, filesize, mod_time])


Expand Down
2 changes: 0 additions & 2 deletions scripts/shift.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

import argparse

LETTERS = "abcdefghijklmnopqrstuvwxyz"
Expand Down
2 changes: 0 additions & 2 deletions scripts/split.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

import json
import re
import subprocess
Expand Down
8 changes: 5 additions & 3 deletions scripts/tag.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import re
from pathlib import Path

from mutagen import MutagenError
from mutagen.oggopus import OggOpus
import re

files = sorted(Path("/path/to/files").glob("*.opus"))

Expand All @@ -17,7 +19,7 @@
# but NOT:
# 11_003_Chapter 3

m = re.match(r'^\d+_\d+_Chapter \d+_(.+)$', stem)
m = re.match(r"^\d+_\d+_Chapter \d+_(.+)$", stem)

if m:
current_book = m.group(1).strip()
Expand All @@ -38,5 +40,5 @@

print(f"{file.name} -> {title}")

except Exception as e:
except (MutagenError, OSError) as e:
print(f"ERROR {file.name}: {e}")
45 changes: 22 additions & 23 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.