dj_angles.caseconverter.caseconverter

Module Contents

dj_angles.caseconverter.caseconverter.logger
class dj_angles.caseconverter.caseconverter.StringBuffer

Bases: io.StringIO

StringBuffer is a wrapper around StringIO.

By wrapping StringIO, adding debugging information is easy.

write(s)

Write string to file.

Returns the number of characters written, which is always equal to the length of the string.

dj_angles.caseconverter.caseconverter.DELIMITERS = ' -_'
dj_angles.caseconverter.caseconverter.stripable_punctuation(delimiters)

Construct a string of stripable punctuation based on delimiters.

Stripable punctuation is defined as all punctuation that is not a delimeter.

class dj_angles.caseconverter.caseconverter.CaseConverter(s, delimiters=DELIMITERS, strip_punctuation=True)
add_boundary_handler(handler)

Add a boundary handler.

define_boundaries()

Define boundary handlers.

define_boundaries() is called when a CaseConverter is initialized. define_boundaries() should be overridden in a child class to add boundary handlers.

A CaseConverter without boundary handlers makes little sense.

delimiters()

Retrieve the delimiters.

raw()

Retrieve the raw string to be converted.

init(input_buffer, output_buffer)

Initialize the output buffer.

Can be overridden.

See convert() for call order.

mutate(c)

Mutate a character not on a boundary.

Can be overridden.

See convert() for call order.

prepare_string(s: str) str

Prepare the raw intput string for conversion.

Executed during CaseConverter initialization providing an opportunity for child classes to manipulate the string. By default, the string is not manipulated.

Can be overridden.

convert() str

Convert the raw string.

convert() follows a series of steps.

  1. Initialize the output buffer using init().

For every character in the input buffer: 2. Check if the current position lies on a boundary as defined by the BoundaryHandler instances. 3. If on a boundary, execute the handler. 4. Else apply a mutation to the character via mutate() and add the mutated character to the output buffer.