From 50492ed0cb85d0e13f8d431f7f583068a4f09309 Mon Sep 17 00:00:00 2001 From: roll Date: Fri, 27 Mar 2020 18:58:22 +0300 Subject: [PATCH] Fix profile being loaded from local path (not supported in the specs) (#259) * Fix profile being loaded from local path * Fixed linting --- datapackage/profile.py | 14 +++++--------- tests/test_profile.py | 1 + 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/datapackage/profile.py b/datapackage/profile.py index 52db93c..e52f55f 100644 --- a/datapackage/profile.py +++ b/datapackage/profile.py @@ -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 @@ -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( diff --git a/tests/test_profile.py b/tests/test_profile.py index 983c033..fee66a8 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -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() == {}