Skip to content

chrizzFTD/naming

Repository files navigation

naming

Build Status Coverage Status Documentation Status PyPI version PyPI

Object-oriented names for the digital era.

naming provides an interface for dealing with naming conventions; from defining them, to identifying names and creating new ones.

Installation

naming is available for Python 3.8+ via PyPI.

$ pip install naming

Example

Please refer to the documentation walkthrough for details on contents and usage.

>>> import naming
>>> class NameFileConvention(naming.Name, naming.File):
...     config = dict(first=r'\w+', last=r'\w+', number=r'\d+')
...
>>> name = NameFileConvention('john doe 07.jpg')
>>> name.last
'doe'
>>> name.number
'07'
>>> name.get(first='jane', number=99)  # returns new name string
'jane doe 99.jpg'
>>> name.last = 'connor'  # mutates current name
>>> name
NameFileConvention("john connor 07.jpg")
>>> name.number = 'not_a_number'
...
ValueError: Can't set field 'number' with invalid value 'not a number' on 'NameFileConvention("john doe 07.jpg")'. A valid field value should match pattern: '\d+'

About

Object-oriented names for the digital era.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages