Repository: frictionlessdata/goodtables-py

Issue:
Posixpath support
Would be great if `goodtables` supported a [pathlib](https://docs.python.org/3/library/pathlib.html) `Posixpath` ... 

Not sure, maybe it's only `stream.open` in `inspector.py`?

Discussion:

Patch:
diff --git a/goodtables/validate.py b/goodtables/validate.py
index 19e85e4..f5d72f2 100644
--- a/goodtables/validate.py
+++ b/goodtables/validate.py
@@ -28,6 +28,15 @@ def validate(source, **options):
     settings['custom_checks'] = options.pop('custom_checks', None)
     settings = {key: value for key, value in settings.items() if value is not None}
 
+    # Support for pathlib.Path
+    if hasattr(source, 'joinpath'):
+        source = str(source)
+    if isinstance(source, list):
+        if source and isinstance(source[0], dict) and 'source' in source[0]:
+            for index, item in enumerate(source):
+                if hasattr(item['source'], 'joinpath'):
+                    source[index]['source'] = str(item['source'])
+
     # Extract/infer preset
     preset = options.pop('preset', None)
     if preset is None:


Test patch:
diff --git a/tests/test_validate.py b/tests/test_validate.py
index f1a78e6..7ae59e4 100644
--- a/tests/test_validate.py
+++ b/tests/test_validate.py
@@ -4,8 +4,10 @@ from __future__ import print_function
 from __future__ import absolute_import
 from __future__ import unicode_literals
 
+import sys
 import json
 import pytest
+from importlib import import_module
 from goodtables import validate
 
 
@@ -123,6 +125,24 @@ def test_validate_datapackage_dialect_header_false(log):
     assert log(report) == []
 
 
+# Source as pathlib.Path
+
+@pytest.mark.skipif(sys.version_info < (3, 4), reason='not supported')
+def test_source_pathlib_path_table():
+    pathlib = import_module('pathlib')
+    report = validate(pathlib.Path('data/valid.csv'))
+    assert report['table-count'] == 1
+    assert report['valid']
+
+
+@pytest.mark.skipif(sys.version_info < (3, 4), reason='not supported')
+def test_source_pathlib_path_datapackage():
+    pathlib = import_module('pathlib')
+    report = validate(pathlib.Path('data/datapackages/valid/datapackage.json'))
+    assert report['table-count'] == 2
+    assert report['valid']
+
+
 # Issues
 
 def test_composite_primary_key_unique_issue_215(log):