diff --git a/cleanbasestation.py b/cleanbasestation.py index d402933..911969f 100644 --- a/cleanbasestation.py +++ b/cleanbasestation.py @@ -62,14 +62,22 @@ NOT_TITLE_CASE = [ TITLE_CASE_EXCEPTION_RE = re.compile('[0-9]') +def contains_upper_and_lower(s): + return any(c.isupper() for c in s) and any(c.islower() for c in s) + + def title_case(s): - if (TITLE_CASE_EXCEPTION_RE.search(s) or + if (contains_upper_and_lower(s) or + TITLE_CASE_EXCEPTION_RE.search(s) or s in NOT_TITLE_CASE or (len(s) <= 3 and s not in TITLE_CASE)): return s else: return s.title() + +# TODO: MCDONNELL -> McDonnell + def fix_type(s): if s is not None: tokens = [p for p in s.split(' ') if p]