Skip to content
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
Empty file modified .coveragerc
100755 → 100644
Empty file.
Empty file modified .gitignore
100755 → 100644
Empty file.
Empty file modified .travis.yml
100755 → 100644
Empty file.
Empty file modified CHANGES.rst
100755 → 100644
Empty file.
Empty file modified README.rst
100755 → 100644
Empty file.
Empty file modified netdiff/info.py
100755 → 100644
Empty file.
7 changes: 4 additions & 3 deletions netdiff/parsers/base.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,21 @@ def _to_python(self, data):
Input data might be:
* a path which points to a JSON file
* a URL which points to a JSON file
(supported schemas: http, https, telnet)
(supported schemes: http, https, telnet)
* a JSON formatted string
* a dict representing a JSON structure
"""
# string
if isinstance(data, six.string_types):
up = urlparse.urlparse(data)
# if it looks like a file path
if True in [data.startswith('./'), data.startswith('../'), data.startswith('/')]:
data = open(data).read()
# if it looks like a HTTP URL
elif data.startswith('http'):
elif up.scheme in ['http', 'https']:
data = requests.get(data, verify=False).content.decode()
# if it looks like a telnet URL
elif data.startswith('telnet'):
elif up.scheme == 'telnet':
up = urlparse.urlparse(data)
telnet_host = up.hostname
telnet_port = up.port
Expand Down