Skip to content
Snippets Groups Projects
Commit c9d7b51d authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Minor type annotation fix

parent 41c6c727
Branches
No related tags found
Loading
...@@ -40,21 +40,21 @@ def export_graph(g: Graph): ...@@ -40,21 +40,21 @@ def export_graph(g: Graph):
print(f"Exported {len(g)} triples to {RESULT_FILE}.") print(f"Exported {len(g)} triples to {RESULT_FILE}.")
def ns_find(elem: etree.ElementBase, query: str): def ns_find(elem: etree._Element, query: str):
"""Wrapper for lxml's `find()` function that automatically uses the default """Wrapper for lxml's `find()` function that automatically uses the default
namespace for all unprefixed tag names. namespace for all unprefixed tag names.
""" """
return elem.find(query, namespaces={"": elem.nsmap[None]}) return elem.find(query, namespaces={"": elem.nsmap[None]})
def ns_findall(elem: etree.ElementBase, query: str): def ns_findall(elem: etree._Element, query: str):
"""Wrapper for lxml's `findall()` function that automatically uses the default """Wrapper for lxml's `findall()` function that automatically uses the default
namespace for all unprefixed tag names. namespace for all unprefixed tag names.
""" """
return elem.findall(query, namespaces={"": elem.nsmap[None]}) return elem.findall(query, namespaces={"": elem.nsmap[None]})
def ns_localname(elem: etree.ElementBase) -> str: def ns_localname(elem: etree._Element) -> str:
"""Get an element's local name, stripping the namespace.""" """Get an element's local name, stripping the namespace."""
return etree.QName(elem).localname return etree.QName(elem).localname
...@@ -119,10 +119,18 @@ def parse_manifest_rec( ...@@ -119,10 +119,18 @@ def parse_manifest_rec(
extract_mosetp.parse_mosetp(graph, f"{SOURCE_DIR}/sco/{id}.html", id) extract_mosetp.parse_mosetp(graph, f"{SOURCE_DIR}/sco/{id}.html", id)
import extract_page
def main(): def main():
g = create_graph() g = create_graph()
parse_manifest(g) parse_manifest(g)
export_graph(g) export_graph(g)
# extract_page.parse_page(
# g,
# f"{SOURCE_DIR}/contenu/pages/pg60.html",
# "pg60",
# )
if __name__ == "__main__": if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment