Misc script fixes

This commit is contained in:
Geoffrey Frogeye 2025-08-04 19:51:54 +02:00
parent 3ba3c3a80e
commit 8557d923a0

View file

@ -1,6 +1,7 @@
#!/usr/bin/env nix-shell
#! nix-shell -i python3 --pure
#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.progressbar2
# vim: filetype=python
# Handles sync-conflict files
@ -9,7 +10,6 @@ import logging
import os
import pickle
import re
import sys
import zlib
import coloredlogs
@ -58,7 +58,7 @@ class Table:
class Database:
VERSION = 1
CONFLICT_PATTERN = re.compile("\.sync-conflict-\d{8}-\d{6}-\w{7}")
CONFLICT_PATTERN = re.compile(r"\.sync-conflict-\d{8}-\d{6}-\w{7}")
def __init__(self, directory):
self.version = Database.VERSION
@ -470,12 +470,12 @@ if __name__ == "__main__":
assert isinstance(database, Database)
except BaseException as e:
raise ValueError("Not a database file")
assert (
database.version <= Database.VERSION
), "Version of the loaded database is too recent"
assert (
database.directory == args.directory
), "Directory of the loaded database doesn't match"
assert database.version <= Database.VERSION, (
"Version of the loaded database is too recent"
)
assert database.directory == args.directory, (
"Directory of the loaded database doesn't match"
)
if database is None:
database = Database(args.directory)