Skip to content

Commit

Permalink
Merge pull request #645 from dandi/rm-name2title
Browse files Browse the repository at this point in the history
Delete name2title()
  • Loading branch information
yarikoptic committed May 21, 2021
2 parents 81045b2 + 56a5990 commit edb49c6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
21 changes: 0 additions & 21 deletions dandi/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
get_module_version,
get_utcnow_datetime,
is_same_time,
name2title,
on_windows,
remap_dict,
)
Expand Down Expand Up @@ -343,26 +342,6 @@ def test_server_info():
assert "services" in data


@pytest.mark.parametrize(
"name,title",
[
("relatedResource", "Related Resource"),
("identifier", "Identifier"),
("wasGeneratedBy", "Was Generated by"),
("sameAs", "Same as"),
("includeInCitation", "Include in Citation"),
("anExtraField", "An Extra Field"),
("propertyID", "Property ID"),
("fieldINeed", "Field I Need"),
("needsADatum", "Needs a Datum"),
("contentUrl", "Content URL"),
("ContactPoint", "Contact Point"),
],
)
def test_name2title(name, title):
assert name2title(name) == title


def test_get_module_version():
import pynwb

Expand Down
42 changes: 0 additions & 42 deletions dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,48 +610,6 @@ def get_instance(dandi_instance_id):
)


TITLE_CASE_LOWER = {
"a",
"an",
"and",
"as",
"but",
"by",
"for",
"in",
"nor",
"of",
"on",
"or",
"the",
"to",
"with",
}


def name2title(name):
# For use in autopopulating the titles of model schema fields
words = []
for w in split_camel_case(name):
w = w.lower()
if w == "id" or w == "url":
w = w.upper()
elif not words or w not in TITLE_CASE_LOWER:
w = w.capitalize()
words.append(w)
return " ".join(words)


def split_camel_case(s):
last_start = 0
# Don't split apart "ID":
for m in re.finditer(r"(?<=I)[A-CE-Z]|(?<=[^I])[A-Z]", s):
yield s[last_start : m.start()]
last_start = m.start()
if last_start < len(s):
yield s[last_start:]


def try_multiple(ntrials, retry, base):
"""
``try_multiple(ntrials, retry, base)(f, *args, **kwargs)`` calls ``f``
Expand Down

0 comments on commit edb49c6

Please sign in to comment.