spines.versioning.core

Core functionality for the spines versioning package.

spines.versioning.core.get_changes(a: [<class 'str'>, typing.List[str]], b: [<class 'str'>, typing.List[str]]) → List[tuple][source]

Gets the full set of changes required to go from a to b

Parameters
  • a (str or list of str) – Text to start from.

  • b (str or list of str) – Text to get changes to get to.

Returns

List of five-tuples of operation, from start index, from end index, to start index and to end index.

Return type

list of tuple

spines.versioning.core.get_diff(a: [<class 'str'>, typing.List[str]], b: [<class 'str'>, typing.List[str]], n=3)[source]

Gets the differences between text data

Parameters
  • a (str or list of str) – Text to compare from.

  • b (str or list of str) – Text to compare with.

  • n (int, optional) – Lines of context to show around differences.

Returns

Differences between the texts.

Return type

str

spines.versioning.core.get_doc_string(obj)[source]

Gets the documentation string for the given object

Parameters

obj (object) – Object to get docstring for.

Returns

Docstring of the given object.

Return type

str

spines.versioning.core.get_function_source(func)[source]

Gets the source code for the given function

Parameters

func (callable) – Function to get source code of.

Returns

Function source code, properly formatted.

Return type

str

spines.versioning.core.slugify(value: str, allow_unicode: bool = False) → str[source]

Slugifys the given string

Convert to ASCII if ‘allow_unicode’ is False. Convert spaces to hyphens. Remove characters that aren’t alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace.

Parameters
  • value (str) – String to slugify.

  • allow_unicode (bool, optional) – Whether or not to allow unicode characters.

Returns

Slugified string.

Return type

str