Codingstyle improvements suggested by ruff preview mode + remove old python compatibility code
Hanno Böck

Hanno Böck commited on 2026-10-19 21:34:20
Zeige 1 geänderte Dateien mit 2 Einfügungen und 7 Löschungen.

... ...
@@ -31,8 +31,7 @@ if not target:
31 31
 
32 32
 old = 0
33 33
 if os.path.isfile(target + "timestamp"):
34
-    with open(target + "timestamp", encoding="ascii") as f:
35
-        old = int(f.read())
34
+    old = int(pathlib.Path(target + "timestamp").read_text(encoding="ascii"))
36 35
 
37 36
 new = int(urllib.request.urlopen(DBURL + "freewvsdb.timestamp").read())
38 37
 
... ...
@@ -43,9 +42,5 @@ if new == old and not args.force:
43 42
 tarball = urllib.request.urlopen(DBURL + str(new) + ".tar.xz").read()
44 43
 
45 44
 tf = tarfile.open(fileobj=io.BytesIO(tarball))
46
-if sys.version_info < (3, 11, 4):
47
-    tf.extractall(path=target)
48
-else:
49 45
 tf.extractall(path=target, filter="data")
50
-with open(target + "timestamp", "w", encoding="ascii") as f:
51
-    f.write(str(new))
46
+pathlib.Path(target + "timestamp").write_text(str(new), encoding="ascii")
52 47