Repository: frictionlessdata/frictionless-py

Issue:
Underscores being replaced by dash in resource names
I've got resources (CSV files) with underscores in the names. When I use `describe_resource` on the resource any underscores in the original name for the CSV being unexpectedly replaced by dashes in the descriptor. I can see the below line in setup.py (line 21), but not sure if its the offending line:
`NAME = PACKAGE.replace("_", "-")`

---

Please preserve this line to notify @roll (lead of this repository)


Discussion:

Patch:
diff --git a/data/table_with_data.csv b/data/table_with_data.csv
new file mode 100644
index 00000000..6d09540e
--- /dev/null
+++ b/data/table_with_data.csv
@@ -0,0 +1,3 @@
+id,name
+1,english
+2,中国人
diff --git "a/data/\320\242\320\260\320\261\320\273\320\270\321\206\320\260.csv" "b/data/\320\242\320\260\320\261\320\273\320\270\321\206\320\260.csv"
new file mode 100644
index 00000000..6d09540e
--- /dev/null
+++ "b/data/\320\242\320\260\320\261\320\273\320\270\321\206\320\260.csv"
@@ -0,0 +1,3 @@
+id,name
+1,english
+2,中国人
diff --git a/frictionless/helpers.py b/frictionless/helpers.py
index 859c5af0..a9990cb4 100644
--- a/frictionless/helpers.py
+++ b/frictionless/helpers.py
@@ -10,7 +10,6 @@ import tempfile
 import datetime
 import platform
 import stringcase
-from slugify import slugify
 from inspect import signature
 from urllib.parse import urlparse
 from importlib import import_module
@@ -144,7 +143,7 @@ def detect_name(source):
         name = os.path.splitext(os.path.basename(source))[0]
     elif isinstance(source, list) and source and isinstance(source[0], str):
         name = os.path.splitext(os.path.basename(source[0]))[0]
-    name = slugify(name).lower()
+    name = slugify(name, regex_pattern=r"[^-a-z0-9._/]")
     return name
 
 
@@ -195,6 +194,18 @@ def is_platform(name):
     return False
 
 
+def slugify(text, **options):
+
+    # Import
+    # There is a conflict between python-slugify and awesome-slugify
+    # So we import from a properl module manually
+    from slugify.slugify import slugify
+
+    # Slugify
+    slug = slugify(text, **options)
+    return slug
+
+
 def is_remote_path(path):
     path = path[0] if path and isinstance(path, list) else path
     return urlparse(path).scheme in config.REMOTE_SCHEMES


Test patch:
diff --git a/tests/describe/test_resource.py b/tests/describe/test_resource.py
index 84fcdbd6..2d226a7d 100644
--- a/tests/describe/test_resource.py
+++ b/tests/describe/test_resource.py
@@ -141,3 +141,9 @@ def test_describe_schema_proper_quote_issue_493():
     resource = describe("data/issue493.csv")
     assert resource.dialect.quote_char == '"'
     assert len(resource.schema.fields) == 126
+
+
+def test_describe_file_with_different_characters_name_issue_600():
+    assert describe("data/table_with_data.csv").name == "table_with_data"
+    assert describe("data/Table With Data.csv").name == "table-with-data"
+    assert describe("data/Таблица.csv").name == "tablitsa"