class documentation

class WordSet(tuple): (source)

View In Hierarchy

Given an identifier, return the words that identifier represents, whether in camel case, underscore-separated, etc. >>> WordSet.parse("camelCase") ('camel', 'Case') >>> WordSet.parse("under_sep") ('under', 'sep') Acronyms should be retained >>> WordSet.parse("firstSNL") ('first', 'SNL') >>> WordSet.parse("you_and_I") ('you', 'and', 'I') >>> WordSet.parse("A simple test") ('A', 'simple', 'test') Multiple caps should not interfere with the first cap of another word. >>> WordSet.parse("myABCClass") ('my', 'ABC', 'Class') The result is a WordSet, so you can get the form you need. >>> WordSet.parse("myABCClass").underscore_separated() 'my_ABC_Class' >>> WordSet.parse('a-command').camel_case() 'ACommand' >>> WordSet.parse('someIdentifier').lowered().space_separated() 'some identifier' Slices of the result should return another WordSet. >>> WordSet.parse('taken-out-of-context')[1:].underscore_separated() 'out_of_context' >>> WordSet.from_class_name(WordSet()).lowered().space_separated() 'word set' >>> example = WordSet.parse('figured it out') >>> example.headless_camel_case() 'figuredItOut' >>> example.dash_separated() 'figured-it-out'

Class Method from_class_name Undocumented
Class Method parse Undocumented
Method __getitem__ Undocumented
Method camel_case Undocumented
Method capitalized Undocumented
Method dash_separated Undocumented
Method headless_camel_case Undocumented
Method lowered Undocumented
Method space_separated Undocumented
Method trim >>> WordSet.parse('foo bar').trim('foo') ('bar',)
Method trim_left Remove the item from the beginning of the set.
Method trim_right Remove the item from the end of the set.
Method underscore_separated Undocumented
Class Variable _pattern Undocumented
@classmethod
def from_class_name(cls, subject): (source)

Undocumented

@classmethod
def parse(cls, identifier): (source)

Undocumented

def __getitem__(self, item): (source)

Undocumented

def camel_case(self): (source)

Undocumented

def capitalized(self): (source)

Undocumented

def dash_separated(self): (source)

Undocumented

def headless_camel_case(self): (source)

Undocumented

def lowered(self): (source)

Undocumented

def space_separated(self): (source)

Undocumented

def trim(self, item): (source)

>>> WordSet.parse('foo bar').trim('foo') ('bar',)

def trim_left(self, item): (source)

Remove the item from the beginning of the set. >>> WordSet.parse('foo bar').trim_left('foo') ('bar',) >>> WordSet.parse('foo bar').trim_left('bar') ('foo', 'bar') >>> WordSet.parse('').trim_left('bar') ()

def trim_right(self, item): (source)

Remove the item from the end of the set. >>> WordSet.parse('foo bar').trim_right('foo') ('foo', 'bar') >>> WordSet.parse('foo bar').trim_right('bar') ('foo',) >>> WordSet.parse('').trim_right('bar') ()

def underscore_separated(self): (source)

Undocumented

_pattern = (source)

Undocumented