dj_angles.caseconverter.caseconverter ===================================== .. py:module:: dj_angles.caseconverter.caseconverter Module Contents --------------- .. py:data:: logger .. py:class:: StringBuffer Bases: :py:obj:`io.StringIO` StringBuffer is a wrapper around StringIO. By wrapping StringIO, adding debugging information is easy. .. py:method:: write(s) Write string to file. Returns the number of characters written, which is always equal to the length of the string. .. py:data:: DELIMITERS :value: ' -_' .. py:function:: stripable_punctuation(delimiters) Construct a string of stripable punctuation based on delimiters. Stripable punctuation is defined as all punctuation that is not a delimeter. .. py:class:: CaseConverter(s, delimiters=DELIMITERS, *, strip_punctuation=True) .. py:attribute:: s .. py:method:: add_boundary_handler(handler) Add a boundary handler. .. py:method:: 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. .. py:method:: delimiters() Retrieve the delimiters. .. py:method:: raw() Retrieve the raw string to be converted. .. py:method:: init(input_buffer, output_buffer) Initialize the output buffer. Can be overridden. See convert() for call order. .. py:method:: mutate(c) Mutate a character not on a boundary. Can be overridden. See convert() for call order. .. py:method:: 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. .. py:method:: 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.