Skip to content

Commit 2c6bda3

Browse files
author
James (ODSC)
authored
Merge pull request #405 from OpenDataServices/2022-11-15
2022 11 15
2 parents c2e5de7 + 9ac2f7b commit 2c6bda3

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
python-version: [ '3.6', '3.7', '3.8', '3.9']
10+
jsonref-version: ["==0.3", ">1"]
1011
steps:
1112
- uses: actions/checkout@v2
1213
- name: Setup python
@@ -21,6 +22,7 @@ jobs:
2122
restore-keys: |
2223
${{ runner.os }}-pip-
2324
- run: pip install --upgrade -r requirements_dev.txt
25+
- run: pip install 'jsonref${{ matrix.jsonref-version }}'
2426
- run: py.test --cov .
2527
- env:
2628
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Make work with multiple versions of jsonref
12+
913
## [0.18.1] - 2022-10-28
1014

1115
### Fixed

flattentool/schema.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,16 @@ class JsonLoaderLocalRefUsedWhenLocalRefsDisabled(Exception):
9797
pass
9898

9999

100-
class JsonLoaderLocalRefsDisabled(jsonref.JsonLoader):
101-
def __call__(self, uri, **kwargs):
102-
if self.is_ref_local(uri):
103-
raise JsonLoaderLocalRefUsedWhenLocalRefsDisabled(
104-
"Local Ref Used When Local Refs Disabled: " + uri
105-
)
106-
else:
107-
return super(JsonLoaderLocalRefsDisabled, self).__call__(uri, **kwargs)
100+
def jsonloader_local_refs_disabled(uri, **kwargs):
101+
if is_ref_local(uri):
102+
raise JsonLoaderLocalRefUsedWhenLocalRefsDisabled(
103+
"Local Ref Used When Local Refs Disabled: " + uri
104+
)
105+
return jsonref.jsonloader(uri, **kwargs)
106+
108107

109-
def is_ref_local(self, uri):
110-
return uri[:7].lower() != "http://" and uri[:8].lower() != "https://"
108+
def is_ref_local(uri):
109+
return uri[:7].lower() != "http://" and uri[:8].lower() != "https://"
111110

112111

113112
class SchemaParser(object):
@@ -159,7 +158,7 @@ def __init__(
159158
self.root_schema_dict = jsonref.load(
160159
schema_file,
161160
object_pairs_hook=OrderedDict,
162-
loader=JsonLoaderLocalRefsDisabled(),
161+
loader=jsonloader_local_refs_disabled,
163162
)
164163
else:
165164
if sys.version_info[:2] > (3, 0):

flattentool/tests/test_schema_parser.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
import pytest
44

5-
from flattentool.schema import (
6-
JsonLoaderLocalRefsDisabled,
7-
SchemaParser,
8-
get_property_type_set,
9-
)
5+
from flattentool.schema import SchemaParser, get_property_type_set, is_ref_local
106
from flattentool.sheet import Sheet
117

128
type_string = {"type": "string"}
@@ -767,7 +763,7 @@ def test_schema_from_uri(httpserver):
767763
"data", test_json_loader_local_refs_disabled_is_ref_local_data_returns_true
768764
)
769765
def test_json_loader_local_refs_disabled_is_ref_local_true(data):
770-
assert True == JsonLoaderLocalRefsDisabled().is_ref_local(data)
766+
assert True == is_ref_local(data)
771767

772768

773769
test_json_loader_local_refs_disabled_is_ref_local_data_returns_false = [
@@ -784,4 +780,4 @@ def test_json_loader_local_refs_disabled_is_ref_local_true(data):
784780
"data", test_json_loader_local_refs_disabled_is_ref_local_data_returns_false
785781
)
786782
def test_json_loader_local_refs_disabled_is_ref_local_true(data): # noqa
787-
assert False == JsonLoaderLocalRefsDisabled().is_ref_local(data)
783+
assert False == is_ref_local(data)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run(self):
2828

2929

3030
install_requires = [
31-
"jsonref<1",
31+
"jsonref",
3232
"schema",
3333
"openpyxl>=2.6,!=3.0.2",
3434
"pytz",

0 commit comments

Comments
 (0)