ogc-na 0.3.41__py3-none-any.whl → 0.3.43__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 +2 -2
- ogc/na/annotate_schema.py +18 -2
- ogc/na/input_filters/xml.py +4 -0
- {ogc_na-0.3.41.dist-info → ogc_na-0.3.43.dist-info}/METADATA +12 -1
- {ogc_na-0.3.41.dist-info → ogc_na-0.3.43.dist-info}/RECORD +7 -7
- {ogc_na-0.3.41.dist-info → ogc_na-0.3.43.dist-info}/WHEEL +0 -0
- {ogc_na-0.3.41.dist-info → ogc_na-0.3.43.dist-info}/top_level.txt +0 -0
ogc/na/_version.py
CHANGED
ogc/na/annotate_schema.py
CHANGED
|
@@ -434,13 +434,15 @@ class SchemaAnnotator:
|
|
|
434
434
|
"""
|
|
435
435
|
|
|
436
436
|
def __init__(self, schema_resolver: SchemaResolver | None = None,
|
|
437
|
-
ref_mapper: Callable[[str, Any], str] | None = None
|
|
437
|
+
ref_mapper: Callable[[str, Any], str] | None = None,
|
|
438
|
+
ignore_existing: bool = False):
|
|
438
439
|
"""
|
|
439
440
|
:schema_resolver: an optional SchemaResolver to resolve references
|
|
440
441
|
:ref_mapper: an optional function to map JSON `$ref`'s before resolving them
|
|
441
442
|
"""
|
|
442
443
|
self.schema_resolver = schema_resolver or SchemaResolver()
|
|
443
444
|
self._ref_mapper = ref_mapper
|
|
445
|
+
self.ignore_existing = ignore_existing
|
|
444
446
|
|
|
445
447
|
def process_schema(self, location: Path | str | None,
|
|
446
448
|
default_context: str | Path | dict | None = None,
|
|
@@ -516,6 +518,14 @@ class SchemaAnnotator:
|
|
|
516
518
|
# skip JSON-LD keywords
|
|
517
519
|
continue
|
|
518
520
|
prop_value = properties[prop]
|
|
521
|
+
|
|
522
|
+
if not isinstance(prop_value, dict):
|
|
523
|
+
continue
|
|
524
|
+
|
|
525
|
+
for key in list(prop_value.keys()):
|
|
526
|
+
if self.ignore_existing and key.startswith(ANNOTATION_PREFIX):
|
|
527
|
+
prop_value.pop(key, None)
|
|
528
|
+
|
|
519
529
|
prop_ctx = find_prop_context(prop, context_stack)
|
|
520
530
|
if prop_ctx:
|
|
521
531
|
used_terms.add(prop)
|
|
@@ -949,6 +959,12 @@ def _main():
|
|
|
949
959
|
help='Dump visited properties and their ids to a file',
|
|
950
960
|
)
|
|
951
961
|
|
|
962
|
+
parser.add_argument(
|
|
963
|
+
'--ignore-existing',
|
|
964
|
+
help="Ignore existing x-jsonld- properties when annotating",
|
|
965
|
+
action='store_true',
|
|
966
|
+
)
|
|
967
|
+
|
|
952
968
|
args = parser.parse_args()
|
|
953
969
|
|
|
954
970
|
if not args.schema:
|
|
@@ -976,7 +992,7 @@ def _main():
|
|
|
976
992
|
with open(args.dump_visited, 'w', newline='') as f:
|
|
977
993
|
write_visited(f)
|
|
978
994
|
else:
|
|
979
|
-
annotator = SchemaAnnotator()
|
|
995
|
+
annotator = SchemaAnnotator(ignore_existing=args.ignore_existing)
|
|
980
996
|
annotated = annotator.process_schema(args.schema, args.context)
|
|
981
997
|
print(dump_yaml(annotated.schema))
|
|
982
998
|
|
ogc/na/input_filters/xml.py
CHANGED
|
@@ -13,6 +13,8 @@ Configuration values:
|
|
|
13
13
|
* `namespace-separator` (default `:`): String that will be used to separate the namespace prefix and the local name
|
|
14
14
|
when processing namespaces.
|
|
15
15
|
* `text-property` (default: `_`): property name that will be used to put the element's text content into
|
|
16
|
+
* `disable-entities` (default: `True`): disable processing of XML entities (to avoid XXE injections when parsing
|
|
17
|
+
untrusted data)
|
|
16
18
|
"""
|
|
17
19
|
from __future__ import annotations
|
|
18
20
|
|
|
@@ -28,6 +30,7 @@ DEFAULT_CONF = {
|
|
|
28
30
|
'attr-prefix': '_',
|
|
29
31
|
'namespace-separator': ':',
|
|
30
32
|
'text-property': '_',
|
|
33
|
+
'disable-entities': True,
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
|
|
@@ -47,6 +50,7 @@ def apply_filter(content: bytes, conf: dict[str, Any] | None) -> tuple[dict[str,
|
|
|
47
50
|
attr_prefix=conf['attr-prefix'],
|
|
48
51
|
namespace_separator=conf['namespace-separator'],
|
|
49
52
|
cdata_key=conf['text-property'],
|
|
53
|
+
disable_entities=conf['disable-entities'],
|
|
50
54
|
)
|
|
51
55
|
|
|
52
56
|
return result, metadata
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ogc_na
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.43
|
|
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/
|
|
@@ -42,6 +42,14 @@ Requires-Dist: mkdocs-markdownextradata-plugin ; extra == 'dev'
|
|
|
42
42
|
|
|
43
43
|
# ogc-na-tools
|
|
44
44
|
|
|
45
|
+
## TL;DR
|
|
46
|
+
|
|
47
|
+
You can install the tools with `pip`:
|
|
48
|
+
|
|
49
|
+
```shell
|
|
50
|
+
pip install ogc-na
|
|
51
|
+
```
|
|
52
|
+
|
|
45
53
|
## Purpose
|
|
46
54
|
This repository contains tools used to maintain controlled vocabularies and knowledge assets managed by the OGC Naming Authority. Such tools may have wider general applicability and be refactored into tool specific repositories.
|
|
47
55
|
|
|
@@ -67,6 +75,9 @@ The following tools are currently available:
|
|
|
67
75
|
|
|
68
76
|
## Development
|
|
69
77
|
|
|
78
|
+
Note: This is only necessary if you are going to work *on* the tools themselves, not *with* them (see [TL;DR](#tldr)
|
|
79
|
+
above).
|
|
80
|
+
|
|
70
81
|
To install runtime and development dependencies, run:
|
|
71
82
|
|
|
72
83
|
```shell
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
ogc/na/__init__.py,sha256=uzcNiJ3uKFNJ1HBfKxIwgAy2HMUFsLAe5RkrUg8ncac,464
|
|
2
|
-
ogc/na/_version.py,sha256=
|
|
3
|
-
ogc/na/annotate_schema.py,sha256=
|
|
2
|
+
ogc/na/_version.py,sha256=3SM8TQK0XTeTAO_UFFJd4QeOtXiE6t02ayy_xRZ5U98,413
|
|
3
|
+
ogc/na/annotate_schema.py,sha256=zhg8sBSWcfr1JlGALomrKVhrmJQ8HMkIfLVf1yqQg9I,39592
|
|
4
4
|
ogc/na/domain_config.py,sha256=C6ao37dbXEKv_K7WcfzQgI3H1Hr3c4-3p24hgl2oH54,13896
|
|
5
5
|
ogc/na/download.py,sha256=2afrLyl4WsAlxkCgXsl47fs9mNKfDmhVpeT2iwNSoq0,3354
|
|
6
6
|
ogc/na/gsp.py,sha256=KGa2G9i8kPefYTHNPUDoXnNyF7Tiwt8K__Ew_Qa7eeg,6048
|
|
@@ -13,8 +13,8 @@ ogc/na/util.py,sha256=ayMUT9HzNKynpSDTZ8epM8qSMTu4-_KlEL-Zlci2Pnk,11573
|
|
|
13
13
|
ogc/na/validation.py,sha256=5xjHH55NZKM8HtUk8XgVzm8W5ZlZY00u_qsWfXK_8dM,3732
|
|
14
14
|
ogc/na/input_filters/__init__.py,sha256=AhE7n_yECwxFKwOM3Jc0ft96TtF5i_Z-fHrS4HYOjaE,1179
|
|
15
15
|
ogc/na/input_filters/csv.py,sha256=nFfB1XQF_QApcGGzMqEvzD_b3pBtCtsfUECsZ9UGE6s,2616
|
|
16
|
-
ogc/na/input_filters/xml.py,sha256=
|
|
17
|
-
ogc_na-0.3.
|
|
18
|
-
ogc_na-0.3.
|
|
19
|
-
ogc_na-0.3.
|
|
20
|
-
ogc_na-0.3.
|
|
16
|
+
ogc/na/input_filters/xml.py,sha256=9qYjp_w5JLInFM48zB15IYH9eTafjp1Aqd_8kfuW3aA,2074
|
|
17
|
+
ogc_na-0.3.43.dist-info/METADATA,sha256=tANOeQvrhO_4uhdtrPJs2zpyG7gjSA-3InVOt-5_mx0,3796
|
|
18
|
+
ogc_na-0.3.43.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
19
|
+
ogc_na-0.3.43.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
|
|
20
|
+
ogc_na-0.3.43.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|