Skip to content

Commit

Permalink
fix(typename): improved camelCasing
Browse files Browse the repository at this point in the history
Previously, it was possible to get types like Foo_bar, which is not
desireable.
Now it is totally impossible to see such blasphemy ;)
  • Loading branch information
Byron committed Mar 11, 2015
1 parent 614539a commit de40a8b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,15 @@ def extract_parts(desc):
# ------------------------------------------------------------------------------
## @{

def capitalize(s):
return s[:1].upper() + s[1:]

# Return transformed string that could make a good type name
def canonical_type_name(s):
# can't use s.capitalize() as it will lower-case the remainder of the string
s = s.replace(' ', '')
return s[:1].upper() + s[1:]
s = ''.join(capitalize(t) for t in s.split(' '))
s = ''.join(capitalize(t) for t in s.split('_'))
return capitalize(s)

def nested_type_name(sn, pn):
return sn + canonical_type_name(pn)
Expand Down

0 comments on commit de40a8b

Please sign in to comment.