naming
Project description
titlize/untitlize
from namae import titlize, untitlize
assert titlize("foo") == "Foo"
assert untitlize("Foo") == "foo"
pascalcase/camelcase/snakecase/kebabcase
assert pascalcase("foo-bar") == "FooBar"
assert camelcase("foo-bar") == "fooBar"
assert snakecase("IpAddress") == "ip_address"
assert snakecase("IPAddress") == "ip_address"
assert kebabcase("IPAddress") == "ip-address"
assert lispcase("IPAddress") == "ip-address"
normalize
from namae import normalize
# hyphen
assert normalize("foo-bar") == "foo_bar"
# invalid prefix
assert normalize("foo123") == "foo123"
assert normalize("123foo") == "n123foo"
assert normalize("+1") == "x1"
assert normalize("-1") == "x_1"
# python's keyword
assert normalize("while") == "while_"
assert normalize("def") == "def_"
appendix
goname
from namae.go import goname
assert goname("foo-bar-boo") == 'FooBarBoo'
assert goname("foo_bar_boo") == 'FooBarBoo'
assert goname("api") == 'API'
assert goname("id") == 'ID'
assert goname("fooid") == 'Fooid'
assert goname("foo_id") == 'FooID'
assert goname("1times") == 'OneTimes'
assert goname("9times") == 'NineTimes'
assert goname("10times") == 'Num10Times'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
namae-0.1.tar.gz
(3.0 kB
view hashes)