From 44322a64745c468d5746434129f03834d3d589ab Mon Sep 17 00:00:00 2001 From: Claudio Pisa Date: Mon, 4 May 2015 23:39:28 +0200 Subject: [PATCH 1/2] use urlparse schema property instead of startswith() --- netdiff/parsers/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/netdiff/parsers/base.py b/netdiff/parsers/base.py index ffdb279..37612df 100755 --- a/netdiff/parsers/base.py +++ b/netdiff/parsers/base.py @@ -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 From ff59437a6dbf8594b17dd9a85ace8701f306b94d Mon Sep 17 00:00:00 2001 From: Claudio Pisa Date: Mon, 4 May 2015 23:40:58 +0200 Subject: [PATCH 2/2] remove executable flag from some files --- .coveragerc | 0 .gitignore | 0 .travis.yml | 0 CHANGES.rst | 0 README.rst | 0 netdiff/info.py | 0 netdiff/parsers/base.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 .coveragerc mode change 100755 => 100644 .gitignore mode change 100755 => 100644 .travis.yml mode change 100755 => 100644 CHANGES.rst mode change 100755 => 100644 README.rst mode change 100755 => 100644 netdiff/info.py mode change 100755 => 100644 netdiff/parsers/base.py diff --git a/.coveragerc b/.coveragerc old mode 100755 new mode 100644 diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/.travis.yml b/.travis.yml old mode 100755 new mode 100644 diff --git a/CHANGES.rst b/CHANGES.rst old mode 100755 new mode 100644 diff --git a/README.rst b/README.rst old mode 100755 new mode 100644 diff --git a/netdiff/info.py b/netdiff/info.py old mode 100755 new mode 100644 diff --git a/netdiff/parsers/base.py b/netdiff/parsers/base.py old mode 100755 new mode 100644