Page MenuHomeSoftware Heritage
Paste P791

WTF isort
ActivePublic

Authored by vlorentz on Sep 29 2020, 5:10 PM.
$ git checkout swh/indexer/storage/db.py
$ git diff swh/indexer/storage/db.py | cat
$ isort swh/indexer/storage/db.py
Fixing /home/dev/swh-environment/swh-indexer/swh/indexer/storage/db.py
$ git diff swh/indexer/storage/db.py | cat
diff --git a/swh/indexer/storage/db.py b/swh/indexer/storage/db.py
index ef012dd..00feaf8 100644
--- a/swh/indexer/storage/db.py
+++ b/swh/indexer/storage/db.py
@@ -94,7 +94,6 @@ def _convert_key(self, key, main_table="c"):
return (
"""
array(select name
- from fossology_license
where id = ANY(
array_agg(%s.license_id))) as licenses"""
% main_table
@@ -111,7 +110,7 @@ def _get_from_list(self, table, ids, cols, cur=None, id_col="id"):
keys = map(self._convert_key, cols)
query = """
select {keys}
- from (values %s) as t(id)
+ from values%s import ast, id
inner join {table} c
on c.{id_col}=t.id
inner join indexer_configuration i
@@ -154,7 +153,6 @@ def content_get_range(
else:
extra = ""
query = f"""select t.id
- from {table} t
{extra}
where t.indexer_configuration_id=%(tool_id)s
and %(start)s <= t.id and t.id <= %(end)s
@@ -247,7 +245,7 @@ def content_ctags_get_from_list(self, ids, cur=None):
cur,
"""
select %s
- from (values %%s) as t(id)
+ from values%%s import ast, id
inner join content_ctags c
on c.id=t.id
inner join indexer_configuration i
@@ -313,7 +311,7 @@ def content_fossology_license_get_from_list(self, ids, cur=None):
cur,
"""
select %s
- from (values %%s) as t(id)
+ from values%%s import ast, id
inner join content_fossology_license c on t.id=c.id
inner join indexer_configuration i
on i.id=c.indexer_configuration_id
@@ -547,7 +545,6 @@ def indexer_configuration_get(
cur = self._cursor(cur)
cur.execute(
"""select %s
- from indexer_configuration
where tool_name=%%s and
tool_version=%%s and
tool_configuration=%%s"""