diff options
author | John Nduli | 2024-06-13 18:50:27 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-06-14 12:04:49 +0300 |
commit | 35358c2bc09959cefce30865557298bbeaab0fa4 (patch) | |
tree | a3e1f95e7018864abc7cf0fea935bcfa0d5f047c /scripts | |
parent | 74b16cf9493f995a0a075ec7291d32203696c5f4 (diff) | |
download | genenetwork3-35358c2bc09959cefce30865557298bbeaab0fa4.tar.gz |
fix: typehints in index-genenetwork script
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/index-genenetwork | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork index e0f6d81..ebf04e7 100755 --- a/scripts/index-genenetwork +++ b/scripts/index-genenetwork @@ -190,8 +190,11 @@ _:node rdf:type gnc:GNWikiEntry ; } GROUP BY ?speciesName ?symbolName """ sparql.setQuery(query) - results = sparql.queryAndConvert()["results"]["bindings"] - for entry in results: + results = sparql.queryAndConvert() + if not isinstance(results, dict): + raise TypeError(f"Expected results to be a dict but found {type(results)}") + bindings = results["results"]["bindings"] + for entry in bindings : x = (entry["speciesName"]["value"], entry["symbolName"]["value"],) cache[x] = entry["comment"]["value"] return cache @@ -221,8 +224,11 @@ _:node rdf:type gnc:GNWikiEntry ; } GROUP BY ?type """ sparql.setQuery(query) - results = sparql.queryAndConvert()["results"]["bindings"] - return results[0]["hash"]["value"] + results = sparql.queryAndConvert() + if not isinstance(results, dict): + raise TypeError(f"Expected results to be a dict but found {type(results)}") + bindings = results["results"]["bindings"] + return bindings[0]["hash"]["value"] # pylint: disable=invalid-name @@ -456,7 +462,7 @@ def is_data_modified(xapian_directory: str, dir_ = pathlib.Path(xapian_directory) with locked_xapian_writable_database(dir_) as db, database_connection(sql_uri) as conn: checksums = " ".join([ - result["Checksum"].bind(str) + str(result["Checksum"].value) for result in query_sql( conn, f"CHECKSUM TABLE {', '.join(db.get_metadata('tables').decode().split())}") |