Simple Smart list implemented

This commit is contained in:
FrederikBaerentsen 2022-06-07 16:28:58 +02:00
parent b1b204ba2e
commit d0786ec265
3 changed files with 69 additions and 4 deletions

View File

@ -128,13 +128,52 @@ def fromdir(root_url, url, content_base_path, content_relative_path):
for e in data: for e in data:
for key, value in e.items(): for key, value in e.items():
print(key) print(key)
query="SELECT * FROM COMICS where " if key == i:
query="SELECT * FROM COMICS where "
for i in value:
first=True
for j,k in i.items():
if j == 'SQL':
query = query + k
if k != '' and j != "SQL":
# print(j,k)
if not first:
query = query + "and "
if type(k) == list:
# print(k)
if j == "series" or j == "title":
firstS = True
query = query + "("
for l in k:
if not firstS:
query = query + "or "
query = query + j + " like '%" + l + "%' "
if firstS:
firstS = False
query = query + ") "
else:
query = query + j + " in ("
firstL = True
for l in k:
if not firstL:
query = query + ","
query = query + "'" + l + "'"
if firstL:
firstL = False
query = query + ") "
sql="SELECT * from COMICS where SERIES like '%" + i+ "%' or Title like '%" + i+ "%';" else:
query = query + j + " like '%" + k + "%' "
if first:
first = False
query = query + ";"
print("----> " + query)
sql = query
#sql="SELECT * from COMICS where SERIES like '%" + i+ "%' or Title like '%" + i+ "%';"
print(sql) print(sql)
s = conn.execute(sql) s = conn.execute(sql)
list=[] #list=[]
for r in s: for r in s:
#print(r) #print(r)
tUrl=f""+r[7].replace("/home/drudoo/ComicsTest/Comics/","/content/") tUrl=f""+r[7].replace("/home/drudoo/ComicsTest/Comics/","/content/")

View File

@ -20,6 +20,16 @@
] ]
}, },
{ {
"DC (BAT)": [
{
"title": "",
"volume": "",
"publisher": "DC Comics",
"series": "Bat",
"issue": ""
}
]
},{
"Marvel": [ "Marvel": [
{ {
"title": "", "title": "",

View File

@ -1,5 +1,11 @@
[ [
{ {
"SQL TEST": [
{
"SQL": "(series like '%Aqua%' or series like '%girl%') and issue in ('1','2','5','10') and title not like '%Annual%'"
}
]
},{
"Man 2020,2019": [ "Man 2020,2019": [
{ {
"title": "Man", "title": "Man",
@ -14,6 +20,16 @@
] ]
}, },
{ {
"DC (BAT)": [
{
"title": "",
"volume": "",
"publisher": "DC Comics",
"series": "Bat",
"issue": ""
}
]
},{
"Marvel": [ "Marvel": [
{ {
"title": "", "title": "",