Skip to content

Commit

Permalink
Generalize handling of entailment paths
Browse files Browse the repository at this point in the history
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
  • Loading branch information
avillar committed Mar 4, 2024
1 parent 76bcd7f commit 2285a8e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ogc/na/update_vocabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2285a8e

Please sign in to comment.