Skip to main content

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

This version

0.1

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)

Uploaded source

Built Distribution

namae-0.1-py2.py3-none-any.whl (4.3 kB view hashes)

Uploaded 3 5

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page