Fixed complexity

This commit is contained in:
Dimitris Zlatanidis 2022-05-29 18:05:13 +03:00
parent 2079814560
commit 79f4355913

View file

@ -74,37 +74,26 @@ class Database:
bar = Bar("Database sbo creating", max=len(sbo_file), bar = Bar("Database sbo creating", max=len(sbo_file),
suffix="%(percent)d%% - %(eta)ds") suffix="%(percent)d%% - %(eta)ds")
cache = [] # init cache
for i, line in enumerate(sbo_file, 1): for i, line in enumerate(sbo_file, 1):
if line.startswith(self.sbo[0]): for s in self.sbo:
name = line.replace(self.sbo[0], "").strip() if line.startswith(s):
if line.startswith(self.sbo[1]): line = line.replace(s, "").strip()
location = line.replace(self.sbo[1], "").strip() cache.append(line)
if line.startswith(self.sbo[2]):
files = line.replace(self.sbo[2], "").strip()
if line.startswith(self.sbo[3]):
version = line.replace(self.sbo[3], "").strip()
if line.startswith(self.sbo[4]):
download = line.replace(self.sbo[4], "").strip()
if line.startswith(self.sbo[5]):
download64 = line.replace(self.sbo[5], "").strip()
if line.startswith(self.sbo[6]):
md5sum = line.replace(self.sbo[6], "").strip()
if line.startswith(self.sbo[7]):
md5sum64 = line.replace(self.sbo[7], "").strip()
if line.startswith(self.sbo[8]):
requires = line.replace(self.sbo[8], "").strip()
if line.startswith(self.sbo[9]):
short_desc = line.replace(self.sbo[9], "").strip()
if i % 11 == 0: if (i % 11) == 0:
values = [(name, location, files, version, download, values = [
download64, md5sum, md5sum64, requires, short_desc), (cache[0], cache[1], cache[2], cache[3], cache[4],
] cache[5], cache[6], cache[7], cache[8], cache[9]),
]
self.cur.executemany("""INSERT INTO {} VALUES self.cur.executemany("""INSERT INTO {} VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""".format( (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""".format(
self.table_name), values) self.table_name), values)
self.con.commit() self.con.commit()
cache = [] # reset cache after line
bar.next() bar.next()
bar.finish() bar.finish()
self.con.close() self.con.close()