Code cleanup

This commit is contained in:
Dirk Müller 2024-05-16 15:47:45 +02:00
parent f5ffc83a69
commit 39fde7744a
No known key found for this signature in database
8 changed files with 5 additions and 12 deletions

View File

@ -14,8 +14,6 @@ def config(filename="database.ini", section="production"):
for param in params:
db[param[0]] = param[1]
else:
raise Exception(
f"Section {section} not found in the {filename} file"
)
raise Exception(f"Section {section} not found in the {filename} file")
return db

View File

@ -26,11 +26,10 @@ class DB:
def schema_version(self):
# create a cursor
with self.conn.cursor() as cur:
# execute a statement
try:
cur.execute("SELECT MAX(version) from scheme")
except psycopg.errors.UndefinedTable as error:
except psycopg.errors.UndefinedTable:
cur.close()
self.close()
self.connect()

View File

@ -2,7 +2,6 @@ from __future__ import annotations
from hashlib import md5
from pathlib import Path
from typing import Optional
from lib.db import DB
from lib.obs_revision import OBSRevision
@ -206,7 +205,7 @@ class DBRevision:
):
continue
cur.execute(
"""INSERT INTO files (name, md5, size, mtime, revision_id)
"""INSERT INTO files (name, md5, size, mtime, revision_id)
VALUES (%s,%s,%s,%s,%s)""",
(
entry.get("name"),

View File

@ -42,7 +42,7 @@ class GitExporter:
if os.path.exists(self.state_file):
with open(self.state_file) as f:
state_data = yaml.safe_load(f)
if type(state_data) != dict:
if not isinstance(state_data, dict):
state_data = {}
left_to_commit = []
for flat in reversed(flats):

View File

@ -167,7 +167,7 @@ class Importer:
with self.db.cursor() as cur:
cur.execute(
"SELECT * FROM revisions WHERE package=%s AND broken=FALSE AND expanded_srcmd5 IS NULL",
(package, )
(package,),
)
return [DBRevision(self.db, row) for row in cur.fetchall()]

View File

@ -165,7 +165,6 @@ class OBS:
cachedir: str,
file_md5: str,
) -> None:
cached_file = self._path_from_md5(name, cachedir, file_md5)
if not self.in_cache(name, cachedir, file_md5):
with (dirpath / name).open("wb") as f:

View File

@ -41,7 +41,6 @@ class ProxySHA256:
}
def put(self, project, package, name, revision, file_md5, size):
if not self.mime:
self.mime = magic.Magic(mime=True)

View File

@ -1,4 +1,3 @@
from typing import Dict
from xmlrpc.client import Boolean
from lib.db_revision import DBRevision