From 2285a8eb8588d588baef16d22e3f007d8a129bd8 Mon Sep 17 00:00:00 2001 From: Alejandro Villar Date: Mon, 4 Mar 2024 11:32:48 +0100 Subject: [PATCH] Generalize handling of entailment paths Do not assume we want the same layout as in the NamingAuthority repo. If no root and no output directory is provided, create an "entailed" subdirectory in the same path as the entailed file, which makes more sense for other projects --- ogc/na/update_vocabs.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ogc/na/update_vocabs.py b/ogc/na/update_vocabs.py index 44f3929..7ce48a1 100644 --- a/ogc/na/update_vocabs.py +++ b/ogc/na/update_vocabs.py @@ -182,6 +182,9 @@ def make_rdf(filename: Union[str, Path], g: Graph, rootpath: Union[str, None] = filename = Path(filename) filename = filename.resolve() + if isinstance(entailment_directory, Path): + entailment_directory = entailment_directory.resolve() + loadable_ttl = None newbasepath, canonical_filename, conceptschemeuri = \ get_entailed_base_path(filename, g, rootpath, entailment_directory) @@ -453,13 +456,8 @@ def add_artifact(a: Union[str, Path]): if output_path: output_doc = output_path.resolve() / docrelpath entailment_dir = output_doc.parent / args.entailment_directory - output_doc = entailment_dir / output_doc.name else: - entailment_dir = Path(args.entailment_directory).resolve() - output_doc = entailment_dir / doc.name - - os.makedirs(output_doc.parent, exist_ok=True) - os.makedirs(entailment_dir, exist_ok=True) + entailment_dir = DEFAULT_ENTAILED_DIR loadable_path = make_rdf(doc, newg, cfg.uri_root_filter, entailment_dir, provenance_metadata)