Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added s3 to the remote schemes #246

Merged
merged 4 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datapackage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# Module API

REMOTE_SCHEMES = ['http', 'https', 'ftp', 'ftps', 's3']
TABULAR_FORMATS = ['csv', 'tsv', 'xls', 'xlsx']
DEFAULT_DATA_PACKAGE_PROFILE = 'data-package'
DEFAULT_RESOURCE_PROFILE = 'data-resource'
Expand Down
6 changes: 3 additions & 3 deletions datapackage/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import requests
from copy import deepcopy
from tableschema import Table, Storage
from six.moves.urllib.parse import urljoin
from six.moves.urllib.parse import urljoin, urlparse
from six.moves.urllib.request import urlopen
from .profile import Profile
from . import exceptions
Expand Down Expand Up @@ -489,10 +489,10 @@ def _inspect_source(data, path, base_path, storage):
elif len(path) == 1:

# Remote
if path[0].startswith('http'):
if urlparse(path[0]).scheme in config.REMOTE_SCHEMES:
inspection['source'] = path[0]
inspection['remote'] = True
elif base_path and base_path.startswith('http'):
elif base_path and urlparse(base_path).scheme in config.REMOTE_SCHEMES:
norm_base_path = base_path if base_path.endswith('/') else base_path + '/'
inspection['source'] = urljoin(norm_base_path, path[0])
inspection['remote'] = True
Expand Down