Skip to content

Commit 5a8df54

Browse files
committed
Implement @dimitri-yatsenko suggestion
1 parent 858265c commit 5a8df54

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

datajoint/utils.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ def get_master(full_table_name: str) -> str:
5353
return match["master"] + "`" if match else ""
5454

5555

56-
def contains_non_ascii_char(s):
57-
"""
58-
Check if a string contains non-ASCII characters.
59-
60-
:param s: string to check
61-
:returns: True if the string contains any non-ASCII characters, False otherwise
62-
Example:
63-
>>> contains_non_ascii_char("Hello") # returns False
64-
>>> contains_non_ascii_char("HelloΣ") # returns True
65-
"""
66-
return any(ord(c) > 127 for c in s)
67-
68-
6956
def is_camel_case(s):
7057
"""
7158
Check if a string is in CamelCase notation.
@@ -76,9 +63,7 @@ def is_camel_case(s):
7663
>>> is_camel_case("TableName") # returns True
7764
>>> is_camel_case("table_name") # returns False
7865
"""
79-
return re.match(
80-
r"^[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)*$", s
81-
) is not None and not contains_non_ascii_char(s)
66+
return bool(re.match(r"^[A-Z][A-Za-z0-9]*$", s))
8267

8368

8469
def to_camel_case(s):

tests/test_utils.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from_camel_case,
88
to_camel_case,
99
is_camel_case,
10-
contains_non_ascii_char,
1110
)
1211
import pytest
1312

@@ -23,9 +22,7 @@ def test_is_camel_case():
2322
assert not is_camel_case("hello world")
2423
assert not is_camel_case("#baisc_names")
2524
assert not is_camel_case("alphaBeta")
26-
non_ascii_class_name = "TestΣ"
27-
assert contains_non_ascii_char(non_ascii_class_name)
28-
assert not is_camel_case(non_ascii_class_name)
25+
assert not is_camel_case("TestΣ")
2926

3027

3128
def test_from_camel_case():

0 commit comments

Comments
 (0)