Skip to content

Commit

Permalink
Fix profile being loaded from local path (not supported in the specs) (
Browse files Browse the repository at this point in the history
…#259)

* Fix profile being loaded from local path

* Fixed linting
  • Loading branch information
roll authored Mar 27, 2020
1 parent 8336f0c commit 50492ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
14 changes: 5 additions & 9 deletions datapackage/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
from __future__ import print_function
from __future__ import unicode_literals

import os
import six
import copy
import json
import warnings
import requests
import jsonschema
Expand Down Expand Up @@ -100,17 +98,15 @@ def _load_registry(self):
def _load_schema(self, schema, registry):
the_schema = schema

# For a reference:
# https://frictionlessdata.io/specs/profiles/
if isinstance(schema, six.string_types):
try:
the_schema = registry.get(schema)
if not the_schema:
if os.path.isfile(schema):
with open(schema, 'r') as f:
the_schema = json.load(f)
else:
req = requests.get(schema)
req.raise_for_status()
the_schema = req.json()
req = requests.get(schema)
req.raise_for_status()
the_schema = req.json()
except (IOError, ValueError, requests.exceptions.RequestException) as ex:
message = 'Unable to load profile at "{0}"'
six.raise_from(
Expand Down
1 change: 1 addition & 0 deletions tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_init_changing_the_original_schema_dict_doesnt_change_schema():
assert 'bar' not in schema.to_dict()


@pytest.mark.skip('Not supported: https://frictionlessdata.io/specs/profiles/')
def test_init_loads_schema_from_path():
assert Profile('data/empty_schema.json').to_dict() == {}

Expand Down

0 comments on commit 50492ed

Please sign in to comment.