Repository: TabViewer/tabview

Issue:
File URI scheme not supported
File URI scheme as filename is not supported:

`$ tabview file://home/asparagii/test.csv` leads to a FileNotFoundException

Discussion:
firecat53: Happy to merge this. Can you please provide unit tests?
asparagii: Sure thing. Where should I put them? Everything in the same file?

Patch:
diff --git a/tabview/tabview.py b/tabview/tabview.py
index c98188a..b7f441c 100644
--- a/tabview/tabview.py
+++ b/tabview/tabview.py
@@ -25,6 +25,11 @@ from textwrap import wrap
 import unicodedata
 import shlex
 
+if sys.version_info.major < 3:
+    from urlparse import urlparse
+else:
+    from urllib.parse import urlparse
+
 
 if sys.version_info.major < 3:
     # Python 2.7 shim
@@ -1356,7 +1361,8 @@ def view(data, enc=None, start_pos=(0, 0), column_width=20, column_gap=2,
         while True:
             try:
                 if isinstance(data, basestring):
-                    with open(data, 'rb') as fd:
+                    parsed_path = parse_path(data)
+                    with open(parsed_path, 'rb') as fd:
                         new_data = fd.readlines()
                         if info == "":
                             info = data
@@ -1395,3 +1401,8 @@ def view(data, enc=None, start_pos=(0, 0), column_width=20, column_gap=2,
     finally:
         if lc_all is not None:
             locale.setlocale(locale.LC_ALL, lc_all)
+
+
+def parse_path(path):
+    parse_result = urlparse(path)
+    return parse_result.path


Test patch:
diff --git a/test/test_tabview.py b/test/test_tabview.py
index b82c38e..91f4409 100644
--- a/test/test_tabview.py
+++ b/test/test_tabview.py
@@ -107,6 +107,26 @@ class TestTabviewUnits(unittest.TestCase):
                 i = str(i)
             self.assertEqual(i, res[0][j])
 
+    def test_tabview_uri_parse(self):
+        # Strip 'file://' from uri (three slashes)
+        path = t.parse_path('file:///home/user/test.csv')
+        self.assertEqual(path, '/home/user/test.csv')
+
+        # Two slashes
+        path = t.parse_path('file://localhost/test.csv')
+        self.assertEqual(path, '/test.csv')
+
+        # Don't change if no 'file://' in string
+        path = t.parse_path('/home/user/test.csv')
+        self.assertEqual(path, '/home/user/test.csv')
+
+        # Don't change if relative path
+        path = t.parse_path('../test.csv')
+        self.assertEqual(path, '../test.csv')
+
+        path = t.parse_path('test.csv')
+        self.assertEqual(path, 'test.csv')
+
 
 class TestTabviewIntegration(unittest.TestCase):
     """Integration tests for tabview. Run through the curses routines and some