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),
suffix="%(percent)d%% - %(eta)ds")
cache = [] # init cache
for i, line in enumerate(sbo_file, 1):
if line.startswith(self.sbo[0]):
name = line.replace(self.sbo[0], "").strip()
if line.startswith(self.sbo[1]):
location = line.replace(self.sbo[1], "").strip()
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()
for s in self.sbo:
if line.startswith(s):
line = line.replace(s, "").strip()
cache.append(line)
if i % 11 == 0:
values = [(name, location, files, version, download,
download64, md5sum, md5sum64, requires, short_desc),
]
if (i % 11) == 0:
values = [
(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
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""".format(
self.table_name), values)
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""".format(
self.table_name), values)
self.con.commit()
cache = [] # reset cache after line
bar.next()
bar.finish()
self.con.close()