json-schema-utils 0.9.22__tar.gz → 0.9.23.dev1__tar.gz
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 json-schema-utils might be problematic. Click here for more details.
- {json_schema_utils-0.9.22/json_schema_utils.egg-info → json_schema_utils-0.9.23.dev1}/PKG-INFO +1 -1
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1/json_schema_utils.egg-info}/PKG-INFO +1 -1
- json_schema_utils-0.9.23.dev1/json_schema_utils.egg-info/scm_version.json +8 -0
- json_schema_utils-0.9.23.dev1/jsutils/VERSION +1 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/convert.py +2 -1
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/resolver.py +3 -2
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/scripts.py +4 -2
- json_schema_utils-0.9.22/json_schema_utils.egg-info/scm_version.json +0 -8
- json_schema_utils-0.9.22/jsutils/VERSION +0 -1
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/.gitignore +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/LICENSE +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/MANIFEST.in +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/README.md +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/SOURCES.txt +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/dependency_links.txt +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/entry_points.txt +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/not-zip-safe +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/requires.txt +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/scm_file_list.json +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/top_level.txt +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/__init__.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/inline.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/jtd.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/recurse.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/restruct.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/schemas.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/simplify.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/stats.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/types.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/utils.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/jsutils/vocab.py +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/pyproject.toml +0 -0
- {json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.9.23
|
|
@@ -2163,6 +2163,7 @@ def schema_to_model(
|
|
|
2163
2163
|
typer: bool = False, simpler: bool = False, fix: bool = True,
|
|
2164
2164
|
use_id: bool = False, strict: bool = True, resolve: bool = True,
|
|
2165
2165
|
resilient: bool = False, version: int = 0, level: int = logging.INFO,
|
|
2166
|
+
download: bool = False,
|
|
2166
2167
|
):
|
|
2167
2168
|
"""Convert a JSON Schema to a JSON Model."""
|
|
2168
2169
|
|
|
@@ -2178,7 +2179,7 @@ def schema_to_model(
|
|
|
2178
2179
|
if sid in ID2MODEL:
|
|
2179
2180
|
url = ID2MODEL[sid][0 if fix else 1]
|
|
2180
2181
|
if url is not None:
|
|
2181
|
-
model = f"${url}"
|
|
2182
|
+
model = resolver.get(url) if download else f"${url}"
|
|
2182
2183
|
log.info(f"using predefined model for {sid}: {model}")
|
|
2183
2184
|
else:
|
|
2184
2185
|
log.debug(f"no predefined model for {sid}")
|
|
@@ -25,15 +25,16 @@ class Resolver:
|
|
|
25
25
|
src, dst = m.split("=", 1)
|
|
26
26
|
self._mapping[src] = dst
|
|
27
27
|
|
|
28
|
-
def
|
|
28
|
+
def _urlHash(self, url: str) -> str:
|
|
29
29
|
return hashlib.sha3_256(url.encode()).hexdigest()[:16]
|
|
30
30
|
|
|
31
31
|
def get(self, url: str) -> JsonSchema:
|
|
32
|
+
"""Download JSON from URL."""
|
|
32
33
|
|
|
33
34
|
js, loaded, filed, cached, cfn = None, False, False, False, None
|
|
34
35
|
|
|
35
36
|
if self._cache is not None: # we cache the **initial** url only
|
|
36
|
-
uh = self.
|
|
37
|
+
uh = self._urlHash(url)
|
|
37
38
|
cfn = f"{self._cache}/{uh}.json"
|
|
38
39
|
try:
|
|
39
40
|
with open(cfn) as f:
|
|
@@ -435,6 +435,7 @@ def jsu_model(xargs: list[str]|None = None) -> int:
|
|
|
435
435
|
ap_common(arg)
|
|
436
436
|
arg("--cache", type=str, default=None, help="cache directory for remote schemas")
|
|
437
437
|
arg("--map", "-m", default=[], action="append", help="url local mapping \"src=dst\"")
|
|
438
|
+
arg("--download", "-dl", default=False, action="store_true", help="download model urls")
|
|
438
439
|
|
|
439
440
|
arg("--id", action="store_true", default=False,
|
|
440
441
|
help="enable $id lookup")
|
|
@@ -494,7 +495,7 @@ def jsu_model(xargs: list[str]|None = None) -> int:
|
|
|
494
495
|
vocabularize=args.vocab, modernize=args.modernize,
|
|
495
496
|
simpler=args.simple, typer=args.type, resilient=args.resilient,
|
|
496
497
|
version=args.sversion, resolver=resolver,
|
|
497
|
-
level=args.level,
|
|
498
|
+
level=args.level, download=args.download,
|
|
498
499
|
)
|
|
499
500
|
except Exception as e:
|
|
500
501
|
log.error(e, exc_info=args.level == logging.DEBUG)
|
|
@@ -564,6 +565,7 @@ def jsu_compile(xargs: list[str]|None = None) -> int:
|
|
|
564
565
|
# remote schemas
|
|
565
566
|
arg("--cache", type=str, default=None, help="cache directory for remote schemas")
|
|
566
567
|
arg("--map", "-m", default=[], action="append", help="url local mapping \"src=dst\"")
|
|
568
|
+
arg("--download", "-dl", default=False, action="store_true", help="download model urls")
|
|
567
569
|
|
|
568
570
|
# how to run the jmc backend
|
|
569
571
|
arg("--backend", "-b", type=str, default="p", choices=["p", "f", "n"],
|
|
@@ -614,7 +616,7 @@ def jsu_compile(xargs: list[str]|None = None) -> int:
|
|
|
614
616
|
vocabularize=args.vocab, modernize=args.modernize,
|
|
615
617
|
typer=args.type, simpler=args.simple, resilient=args.resilient,
|
|
616
618
|
version=args.sversion, resolver=resolver,
|
|
617
|
-
level=args.level,
|
|
619
|
+
level=args.level, download=args.download,
|
|
618
620
|
)
|
|
619
621
|
except Exception as e:
|
|
620
622
|
log.error(f"schema to model conversion for {args.schema} failed")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.9.22
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
{json_schema_utils-0.9.22 → json_schema_utils-0.9.23.dev1}/json_schema_utils.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|