ogc-na 0.3.57__py3-none-any.whl → 0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ogc-na might be problematic. Click here for more details.

ogc/na/_version.py CHANGED
@@ -1,8 +1,13 @@
1
- # file generated by setuptools_scm
1
+ # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
3
6
  TYPE_CHECKING = False
4
7
  if TYPE_CHECKING:
5
- from typing import Tuple, Union
8
+ from typing import Tuple
9
+ from typing import Union
10
+
6
11
  VERSION_TUPLE = Tuple[Union[int, str], ...]
7
12
  else:
8
13
  VERSION_TUPLE = object
@@ -12,5 +17,5 @@ __version__: str
12
17
  __version_tuple__: VERSION_TUPLE
13
18
  version_tuple: VERSION_TUPLE
14
19
 
15
- __version__ = version = '0.3.57'
16
- __version_tuple__ = version_tuple = (0, 3, 57)
20
+ __version__ = version = '0.4'
21
+ __version_tuple__ = version_tuple = (0, 4)
ogc/na/update_vocabs.py CHANGED
@@ -40,6 +40,7 @@ from rdflib import Graph, RDF, SKOS, URIRef
40
40
 
41
41
  from ogc.na import util
42
42
  from ogc.na.domain_config import DomainConfiguration, DomainConfigurationEntry
43
+ from ogc.na.profile import ProfileRegistry
43
44
  from ogc.na.provenance import generate_provenance, ProvenanceMetadata, FileProvenanceMetadata
44
45
 
45
46
  logger = logging.getLogger('ogc.na.update_vocabs')
@@ -245,6 +246,7 @@ def _main():
245
246
 
246
247
  parser.add_argument(
247
248
  "domain_cfg",
249
+ nargs="?",
248
250
  metavar="domain-cfg",
249
251
  help=("Domain configuration (can be a local or remote RDF file, "
250
252
  "or a SPARQL endpoint in the form 'sparql:http://example.org/sparql')"),
@@ -362,6 +364,17 @@ def _main():
362
364
  help='Ignore errors when retrieving profile artifacts'
363
365
  )
364
366
 
367
+ parser.add_argument(
368
+ '--graph-uri',
369
+ help='Override graph URI that will be used for all resources',
370
+ )
371
+
372
+ parser.add_argument(
373
+ '--profile-uris',
374
+ nargs='*',
375
+ help='Override profile URIs that will be used for all resources',
376
+ )
377
+
365
378
  args = parser.parse_args()
366
379
 
367
380
  setup_logging(args.debug)
@@ -410,29 +423,52 @@ def _main():
410
423
  raise Exception(f"Invalid local artifact mapping: {mappingstr}")
411
424
  local_artifacts_mappings[mapping[0]] = mapping[1]
412
425
 
413
- domain_cfg = DomainConfiguration(args.domain_cfg, working_directory=args.working_directory,
414
- profile_sources=args.profile_source,
415
- ignore_artifact_errors=args.ignore_artifact_errors,
416
- local_artifacts_mappings=local_artifacts_mappings)
417
- cfg_entries = domain_cfg.entries
418
- if not len(cfg_entries):
419
- if args.domain:
420
- logger.warning('No configuration found in %s for domain %s, exiting',
421
- args.domain_cfg, args.domain)
426
+ if not args.domain_cfg and not (args.profile_source and args.profile_uris):
427
+ logger.error('Either a domain configuration or a profile source and a set of '
428
+ 'profile URIs need to be provided')
429
+ sys.exit(2)
430
+
431
+ modified: dict[Path, DomainConfigurationEntry | None]
432
+ added: dict[Path, DomainConfigurationEntry | None]
433
+
434
+ if args.domain_cfg:
435
+ domain_cfg = DomainConfiguration(args.domain_cfg, working_directory=args.working_directory,
436
+ profile_sources=args.profile_source,
437
+ ignore_artifact_errors=args.ignore_artifact_errors,
438
+ local_artifacts_mappings=local_artifacts_mappings)
439
+ cfg_entries = domain_cfg.entries
440
+ if not len(cfg_entries):
441
+ if args.domain:
442
+ logger.warning('No configuration found in %s for domain %s, exiting',
443
+ args.domain_cfg, args.domain)
444
+ else:
445
+ logger.warning('No configuration found in %s exiting', args.domain_cfg)
446
+ sys.exit(1)
447
+
448
+ profile_registry = domain_cfg.profile_registry
449
+
450
+ if args.batch:
451
+ modified = cfg_entries.find_all()
452
+ added = {}
422
453
  else:
423
- logger.warning('No configuration found in %s exiting', args.domain_cfg)
424
- sys.exit(1)
454
+ modified = cfg_entries.find_entries_for_files(mod_list)
455
+ added = cfg_entries.find_entries_for_files(add_list)
425
456
 
426
- profile_registry = domain_cfg.profile_registry
457
+ root_directory = domain_cfg.working_directory
427
458
 
428
- modified: dict[Path, DomainConfigurationEntry]
429
- added: dict[Path, DomainConfigurationEntry]
430
- if args.batch:
431
- modified = cfg_entries.find_all()
432
- added = {}
459
+ elif args.batch:
460
+ logger.error('--batch requires a domain configuration')
461
+ sys.exit(3)
433
462
  else:
434
- modified = cfg_entries.find_entries_for_files(mod_list)
435
- added = cfg_entries.find_entries_for_files(add_list)
463
+ logger.info('Loading profile sources and URIs from script parameters')
464
+ profile_registry = ProfileRegistry(args.profile_source,
465
+ ignore_artifact_errors=args.ignore_artifact_errors,
466
+ local_artifact_mappings=args.local_artifact_mappings)
467
+
468
+ modified = {Path(x): None for x in mod_list}
469
+ added = {Path(x): None for x in add_list}
470
+
471
+ root_directory = Path(args.working_directory or os.getcwd())
436
472
 
437
473
  output_path = Path(args.output_directory) if args.output_directory else None
438
474
 
@@ -448,21 +484,28 @@ def _main():
448
484
  if args.no_provenance:
449
485
  provenance_metadata = None
450
486
  else:
487
+ used = [FileProvenanceMetadata(filename=doc)]
488
+ if args.domain_cfg:
489
+ used.append(FileProvenanceMetadata(filename=args.domain_cfg))
451
490
  provenance_metadata = ProvenanceMetadata(
452
- used=[FileProvenanceMetadata(filename=doc),
453
- FileProvenanceMetadata(filename=args.domain_cfg)],
491
+ used=used,
454
492
  start=datetime.now(),
455
493
  end_auto=True,
456
- root_directory=domain_cfg.working_directory,
494
+ root_directory=root_directory,
457
495
  batch_activity_id=activity_id,
458
496
  activity_label='Entailment and validation',
459
497
  comment=cmdline,
460
498
  base_uri=args.base_uri,
461
499
  )
462
500
 
501
+ if cfg:
502
+ conforms_to = cfg.conforms_to
503
+ else:
504
+ conforms_to = args.profile_uris
505
+
463
506
  origg = Graph().parse(doc)
464
- newg, entail_artifacts = profile_registry.entail(origg, cfg.conforms_to)
465
- validation_result = profile_registry.validate(newg, cfg.conforms_to, log_artifact_errors=True)
507
+ newg, entail_artifacts = profile_registry.entail(origg, conforms_to)
508
+ validation_result = profile_registry.validate(newg, conforms_to, log_artifact_errors=True)
466
509
 
467
510
  if provenance_metadata:
468
511
  def add_artifact(a: Union[str, Path]):
@@ -482,7 +525,7 @@ def _main():
482
525
  else:
483
526
  entailment_dir = DEFAULT_ENTAILED_DIR
484
527
 
485
- loadable_path = make_rdf(doc, newg, cfg.uri_root_filter,
528
+ loadable_path = make_rdf(doc, newg, cfg.uri_root_filter if cfg else None,
486
529
  entailment_dir, provenance_metadata)
487
530
  with open(loadable_path.with_suffix('.txt'), 'w') as validation_file:
488
531
  validation_file.write(validation_result.text)
@@ -495,13 +538,20 @@ def _main():
495
538
  if p != loadable_path:
496
539
  loadables[p] = g
497
540
 
498
- graphname = next(get_graph_uri_for_vocab(newg), None)
541
+ if args.graph_uri:
542
+ graphname = args.graph_uri
543
+ else:
544
+ graphname = next(get_graph_uri_for_vocab(newg), None)
545
+
499
546
  if not graphname:
500
547
  logger.warning("No graph name could be deduced from the vocabulary")
501
548
  # Create graph name from a colon-separated list of
502
549
  # path components relative to the working directory
503
- urnpart = ':'.join(p for p in docrelpath.parts if p and p != '..')
504
- graphname = "x-urn:{}".format(urnpart)
550
+ urnparts = ['x-urn', 'ogc', 'na']
551
+ if cfg and cfg.identifier:
552
+ urnparts.append(str(cfg.identifier))
553
+ urnparts.extend(p for p in docrelpath.parts if p and p != '..')
554
+ graphname = ':'.join(urnparts)
505
555
  append_data = graphname in uploaded_graphs
506
556
  logger.info("Using graph name %s for %s", graphname, str(doc))
507
557
 
@@ -523,7 +573,7 @@ def _main():
523
573
  raise e
524
574
  versioned_gname = f'{graphname}{n + 1}'
525
575
 
526
- report.setdefault(cfg.identifier, {}) \
576
+ report.setdefault(cfg.identifier if cfg else args.graph_uri, {}) \
527
577
  .setdefault(report_cat, []).append(os.path.relpath(doc))
528
578
 
529
579
  for scope, scopereport in report.items():
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: ogc_na
3
- Version: 0.3.57
3
+ Version: 0.4
4
4
  Summary: OGC Naming Authority tools
5
5
  Author-email: Rob Atkinson <ratkinson@ogc.org>, Piotr Zaborowski <pzaborowski@ogc.org>, Alejandro Villar <avillar@ogc.org>
6
6
  Project-URL: Homepage, https://github.com/opengeospatial/ogc-na-tools/
@@ -1,5 +1,5 @@
1
1
  ogc/na/__init__.py,sha256=uzcNiJ3uKFNJ1HBfKxIwgAy2HMUFsLAe5RkrUg8ncac,464
2
- ogc/na/_version.py,sha256=KqIVwYBdIdahVzuj89W2dfY5Y-ewSsfE6L9PQnp8tPw,413
2
+ ogc/na/_version.py,sha256=z4A7Ai6QyXWBOpaj5g4Fi0n9CYi27WfJ6gm02OiXBxE,506
3
3
  ogc/na/annotate_schema.py,sha256=YtxL9pOeeVk9CubvnByUMh7nZUJYZCDQ60hXEvtiR6g,43869
4
4
  ogc/na/domain_config.py,sha256=ORzITa1rTrD1MQdpWYrIVW5SwSa9lJd3hnyHIxNgiIU,13947
5
5
  ogc/na/download.py,sha256=2afrLyl4WsAlxkCgXsl47fs9mNKfDmhVpeT2iwNSoq0,3354
@@ -9,14 +9,14 @@ ogc/na/ingest_json.py,sha256=OUA9IfSpBbwE6bNE2od64iMzdEg-Q4h5iyowgJsn2M4,35659
9
9
  ogc/na/models.py,sha256=nGV8EALtXvmBtkUbu0FA4KOgwNUqQGWIDuMo7UGOKP8,652
10
10
  ogc/na/profile.py,sha256=T7nesbm7azF2ijF60UenJnQQKjIgJlnJ3pUbGT5nYgM,16511
11
11
  ogc/na/provenance.py,sha256=h7UtUb1wW_9MfEim0fjcqkHd0BYmpXqyE1ADzL9AH7I,5551
12
- ogc/na/update_vocabs.py,sha256=GWzWhIvZiCbioyIl3Ln8DHSW_olu5oG17kWGOgxad48,19506
12
+ ogc/na/update_vocabs.py,sha256=9um_Qn3Si6yQ20qLYsFhiaXcxA2ryzduvYprNb252-U,21370
13
13
  ogc/na/util.py,sha256=Ztju3g1YuguUDbk4n2RJfCrl_IIzNAj7linfy24T6VA,12067
14
14
  ogc/na/validation.py,sha256=5xjHH55NZKM8HtUk8XgVzm8W5ZlZY00u_qsWfXK_8dM,3732
15
15
  ogc/na/input_filters/__init__.py,sha256=AhE7n_yECwxFKwOM3Jc0ft96TtF5i_Z-fHrS4HYOjaE,1179
16
16
  ogc/na/input_filters/csv.py,sha256=nFfB1XQF_QApcGGzMqEvzD_b3pBtCtsfUECsZ9UGE6s,2616
17
17
  ogc/na/input_filters/xlsx.py,sha256=X9EpFgC9WwHQD8iUJRGdaDYfgiLKjXPdhTVhDmNPAQ0,2730
18
18
  ogc/na/input_filters/xml.py,sha256=9qYjp_w5JLInFM48zB15IYH9eTafjp1Aqd_8kfuW3aA,2074
19
- ogc_na-0.3.57.dist-info/METADATA,sha256=dcn9t_MBayKk9qKGfH5an7jKwcCpmK8QtDovmc5Ljmw,3843
20
- ogc_na-0.3.57.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
21
- ogc_na-0.3.57.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
22
- ogc_na-0.3.57.dist-info/RECORD,,
19
+ ogc_na-0.4.dist-info/METADATA,sha256=-Fn_jl_HfMJq4QBy8GnlxUzZoN8sbq0wP39mZkH6plg,3840
20
+ ogc_na-0.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
21
+ ogc_na-0.4.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
22
+ ogc_na-0.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5