database: fix duplicated entries

This commit is contained in:
Solene Rapenne 2022-05-05 19:36:23 +02:00
parent 58f9d21b3d
commit 509055ca71
1 changed files with 27 additions and 24 deletions

View File

@ -9,33 +9,36 @@ def main():
conn = sqlite3.connect(database)
data = []
pkgs = dict()
with conn:
cursor = conn.execute("SELECT FULLPKGNAME, COMMENT, DESCR_CONTENTS, WANTLIB, RUN_DEPENDS FROM PortsQ")
for row in cursor:
gui = False
tui = False
if row[3]:
m = re.search("(GL|SDL|gtk-3|X11|Qt5Gui)", row[3])
if m:
gui = True
m = re.search("(curses)", row[3])
if m:
tui = True
if row[4]:
m = re.search("x11/gtk\+3,-guic", row[4])
if m:
gui = True
if not gui and row[2] and row[3] and row[1] and not tui:
m = re.search("(client)", row[3]+row[1]+row[2])
if m:
tui = True
data.append({
"pkgname": row[0], #"-".join(row[0].split("-")[:-1]),
"comment": row[1],
"descr": row[2],
"gui": gui,
"tui": tui
})
if not pkgs.get(row[0]):
pkgs[row[0]] = True
gui = False
tui = False
if row[3]:
m = re.search("(GL|SDL|gtk-3|X11|Qt5Gui)", row[3])
if m:
gui = True
m = re.search("(curses)", row[3])
if m:
tui = True
if row[4]:
m = re.search("x11/gtk\+3,-guic", row[4])
if m:
gui = True
if not gui and row[2] and row[3] and row[1] and not tui:
m = re.search("(client)", row[3]+row[1]+row[2])
if m:
tui = True
data.append({
"pkgname": row[0], #"-".join(row[0].split("-")[:-1]),
"comment": row[1],
"descr": row[2],
"gui": gui,
"tui": tui
})
print(json.dumps(data))
main()