File tree Expand file tree Collapse file tree 7 files changed +37
-12
lines changed Expand file tree Collapse file tree 7 files changed +37
-12
lines changed Original file line number Diff line number Diff line change 41
41
types : [file, yaml]
42
42
entry : yamllint --strict
43
43
- repo : https://github.com/PyCQA/isort
44
- rev : 5.10.1
44
+ rev : 5.12.0
45
45
hooks :
46
46
- id : isort
47
47
args :
71
71
- packaging
72
72
- pytest
73
73
- pytest-mock
74
+ - referencing
74
75
- types-PyYAML
75
76
- types-pkg_resources
76
77
- types-requests
Original file line number Diff line number Diff line change 1
1
#
2
- # This file is autogenerated by pip-compile with python 3.9
3
- # To update, run :
2
+ # This file is autogenerated by pip-compile with Python 3.9
3
+ # by the following command :
4
4
#
5
5
# pip-compile --extra=retry --extra=test --output-file=constraints.txt setup.cfg
6
6
#
7
7
attrs==21.4.0
8
8
# via
9
9
# cattrs
10
10
# pytest
11
+ # referencing
11
12
# requests-cache
12
13
cattrs==22.1.0
13
14
# via requests-cache
@@ -20,9 +21,13 @@ coverage==6.3.3
20
21
exceptiongroup==1.0.0rc5
21
22
# via cattrs
22
23
idna==3.3
23
- # via requests
24
+ # via
25
+ # requests
26
+ # yarl
24
27
iniconfig==1.1.1
25
28
# via pytest
29
+ multidict==6.0.4
30
+ # via yarl
26
31
packaging==21.3
27
32
# via pytest
28
33
platformdirs==2.5.2
@@ -33,8 +38,12 @@ py==1.11.0
33
38
# via pytest
34
39
pyparsing==3.0.9
35
40
# via packaging
41
+ pyrsistent==0.19.3
42
+ # via referencing
36
43
pytest==7.1.2
37
44
# via schemastore (setup.cfg)
45
+ referencing==0.8.11
46
+ # via schemastore (setup.cfg)
38
47
requests==2.27.1
39
48
# via requests-cache
40
49
requests-cache==1.0.0a0
@@ -49,3 +58,5 @@ urllib3==1.26.9
49
58
# via
50
59
# requests
51
60
# requests-cache
61
+ yarl==1.9.2
62
+ # via referencing
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ long_description_content_type = text/markdown
11
11
author = Sorin Sbarnea
12
12
13
13
license = Apache-2.0
14
- license_file = LICENSE
14
+ license_files = LICENSE
15
15
classifiers =
16
16
Development Status :: 5 - Production/Stable
17
17
@@ -56,6 +56,7 @@ zip_safe = False
56
56
57
57
# These are required in actual runtime:
58
58
install_requires =
59
+ referencing
59
60
requests-cache>=1.0.0a0
60
61
61
62
[options.entry_points]
Original file line number Diff line number Diff line change 5
5
from typing import Any
6
6
7
7
import requests_cache
8
+ from referencing import Registry , Resource
9
+ from referencing .jsonschema import Schema , SchemaRegistry
8
10
from requests import HTTPError
9
11
10
12
CATALOG_URL = "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/api/json/catalog.json"
11
13
12
14
13
- class Store :
15
+ class _Store :
14
16
"""Store class for interacting with the store."""
15
17
16
18
def __init__ (self , days : int = 30 ) -> None :
@@ -39,4 +41,14 @@ def refresh(self) -> None:
39
41
print (f"Failed to decode { schema ['url' ]} : { type (exc )} " )
40
42
41
43
42
- __all__ = ["Store" ]
44
+ def registry (** kwargs : Any ) -> SchemaRegistry :
45
+ """Create a registry."""
46
+ store = _Store (** kwargs )
47
+
48
+ def retrieve (uri : str ) -> Resource [Schema ]:
49
+ return Resource .from_contents (store .get_schema (uri ))
50
+
51
+ return Registry (retrieve = retrieve ) # type: ignore
52
+
53
+
54
+ __all__ = ["registry" ]
Original file line number Diff line number Diff line change 1
1
"""Main entry point module."""
2
- from schemastore import Store
2
+ from schemastore import _Store
3
3
4
4
5
5
def main () -> None :
6
6
"""Refresh the cache if needed."""
7
- store = Store ()
7
+ store = _Store ()
8
8
print (f"Catalog has { len (store .catalog ['schemas' ])} schemas" )
9
9
store .refresh ()
10
10
print (f"Catalog now has { len (store .catalog ['schemas' ])} schemas" )
Original file line number Diff line number Diff line change 1
1
"""Test module."""
2
- from schemastore import Store
2
+ import schemastore
3
3
4
4
5
5
def test_one () -> None :
6
6
"""Test one."""
7
- store = Store ()
8
- assert store . catalog is not None
7
+ registry = schemastore . registry ()
8
+ assert registry is not None
You can’t perform that action at this time.
0 commit comments