Skip to content
Snippets Groups Projects
Verified Commit 334f73af authored by Kevin Morris's avatar Kevin Morris
Browse files

cleanup(mkpkglists): Last minute sanitization


Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent e5cd3e1e
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !233. Comments created here will be created in the context of that merge request.
...@@ -7,15 +7,14 @@ Archives: ...@@ -7,15 +7,14 @@ Archives:
packages.gz | A line-separated list of package names packages.gz | A line-separated list of package names
packages-meta-v1.json | A type=search RPC-formatted JSON dataset packages-meta-v1.json | A type=search RPC-formatted JSON dataset
packages-meta-ext-v1.json | An --extended or --all archive packages-meta-ext-v1.json | An --extended archive
pkgbase.gz | A line-separated list of package base names pkgbase.gz | A line-separated list of package base names
users.gz | A line-separated list of user names users.gz | A line-separated list of user names
This script takes an optional argument: --extended or --all. Based This script takes an optional argument: --extended. Based
on the following, right-hand side fields are added to each item. on the following, right-hand side fields are added to each item.
--extended | License, Keywords, Groups --extended | License, Keywords, Groups, relations and dependencies
--all | License, Keywords, Groups, relations and dependencies
""" """
...@@ -131,34 +130,12 @@ def get_extended_dict(query: str): ...@@ -131,34 +130,12 @@ def get_extended_dict(query: str):
if "Keywords" not in data[pkgid]: if "Keywords" not in data[pkgid]:
data[pkgid]["Keywords"] = [] data[pkgid]["Keywords"] = []
if "Groups" not in data[pkgid]:
data[pkgid]["Groups"] = []
data[pkgid][key].append(output) data[pkgid][key].append(output)
conn.close() conn.close()
return data return data
def get_limited_extended_fields():
# Returns: [ID, Type, Name, Cond]
query = """
SELECT PackageGroups.PackageID AS ID, 'Groups' AS Type,
Groups.Name, '' AS Cond
FROM Groups INNER JOIN PackageGroups
ON PackageGroups.GroupID = Groups.ID
UNION SELECT PackageLicenses.PackageID AS ID, 'License' AS Type,
Licenses.Name, '' as Cond
FROM Licenses INNER JOIN PackageLicenses
ON PackageLicenses.LicenseID = Licenses.ID
UNION SELECT Packages.ID AS ID, 'Keywords' AS Type,
PackageKeywords.Keyword AS Name, '' as Cond
FROM PackageKeywords
INNER JOIN Packages ON Packages.PackageBaseID = PackageKeywords.PackageBaseID
"""
return get_extended_dict(query)
def get_extended_fields(): def get_extended_fields():
# Returns: [ID, Type, Name, Cond] # Returns: [ID, Type, Name, Cond]
query = """ query = """
...@@ -190,8 +167,7 @@ def get_extended_fields(): ...@@ -190,8 +167,7 @@ def get_extended_fields():
EXTENDED_FIELD_HANDLERS = { EXTENDED_FIELD_HANDLERS = {
"--extended": get_limited_extended_fields, "--extended": get_extended_fields
"--all": get_extended_fields
} }
...@@ -277,8 +253,6 @@ def main(): ...@@ -277,8 +253,6 @@ def main():
]) ])
update_state(packages_state, update_time) update_state(packages_state, update_time)
else:
print("Packages have not been updated; skipping.")
updated, update_time = should_update(pkgbases_state, "PackageBases") updated, update_time = should_update(pkgbases_state, "PackageBases")
if not updated: if not updated:
...@@ -290,8 +264,6 @@ def main(): ...@@ -290,8 +264,6 @@ def main():
"WHERE PackagerUID IS NOT NULL") "WHERE PackagerUID IS NOT NULL")
f.writelines([bytes(x[0] + "\n", "UTF-8") for x in cur.fetchall()]) f.writelines([bytes(x[0] + "\n", "UTF-8") for x in cur.fetchall()])
update_state(pkgbases_state, update_time) update_state(pkgbases_state, update_time)
else:
print("PackageBases have not been updated; skipping.")
updated, update_time = should_update(users_state, "Users") updated, update_time = should_update(users_state, "Users")
if not updated: if not updated:
...@@ -302,8 +274,6 @@ def main(): ...@@ -302,8 +274,6 @@ def main():
cur = conn.execute("SELECT UserName FROM Users") cur = conn.execute("SELECT UserName FROM Users")
f.writelines([bytes(x[0] + "\n", "UTF-8") for x in cur.fetchall()]) f.writelines([bytes(x[0] + "\n", "UTF-8") for x in cur.fetchall()])
update_state(users_state, update_time) update_state(users_state, update_time)
else:
print("Users have not been updated; skipping.")
conn.close() conn.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment