Skip to content

Commit

Permalink
Merge pull request #198 from choldgraf/adding_URL_error
Browse files Browse the repository at this point in the history
Throwing an error when data8.berkeley.edu URL is passed
  • Loading branch information
SamLau95 committed Feb 16, 2016
2 parents 3683a32 + 8d185f0 commit 6f01091
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions datascience/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ def read_table(cls, filepath_or_buffer, *args, **vargs):
# Look for .csv at the end of the path; use "," as a separator if found
try:
path = urllib.parse.urlparse(filepath_or_buffer).path
if 'data8.berkeley.edu' in filepath_or_buffer:
raise ValueError('data8.berkeley.edu requires authentication, '
'which is not supported.')
except AttributeError:
path = filepath_or_buffer

try:
if 'sep' not in vargs and path.endswith('.csv'):
vargs['sep'] = ','
Expand Down
7 changes: 7 additions & 0 deletions tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,3 +1038,10 @@ def test_array_roundtrip(table):

for (c0, c1) in zip(t.columns, table.columns):
assert_equal(c0, c1)


def test_url_parse():
"""Test that Tables parses URLs correctly"""
with pytest.raises(ValueError):
url = 'https://data8.berkeley.edu/something/something/dark/side'
Table.read_table(url)

0 comments on commit 6f01091

Please sign in to comment.