b.filters : package documentation

Part of bzrlib

Working tree content filtering support.

A filter consists of a read converter, write converter pair. The content in the working tree is called the convenience format while the content actually stored in called the canonical format. The read converter produces canonical content from convenience content while the writer goes the other way.

Converters have the following signatures:

read_converter(chunks) -> chunks
write_converter(chunks, context) -> chunks

where:

Note that context is currently only supported for write converters.

Module eol End of Line Conversion filters.

From the __init__.py module:

Class ContentFilter No class docstring; 1/2 methods documented
Class ContentFilterContext Object providing information that filters can use.
Function filtered_input_file Get an input file that converts external to internal content.
Function filtered_output_bytes Convert byte chunks from internal to external format.
Function internal_size_sha_file_byname Get size and sha of internal content given external content.
Function lazy_register_filter_stack_map Lazily register the filter stacks to use for various preference values.
Function register_filter_stack_map Register the filter stacks to use for various preference values.
Function _get_filter_stack_for Get the filter stack given a sequence of preferences.
Function _get_registered_names Get the list of names with filters registered.
Function _reset_registry Reset the filter stack registry.
def filtered_input_file(f, filters):
Get an input file that converts external to internal content.
Parametersfthe original input file
filtersthe stack of filters to apply
Returnsa file-like object
def filtered_output_bytes(chunks, filters, context=None):
Convert byte chunks from internal to external format.
Parameterschunksan iterator containing the original content
filtersthe stack of filters to apply
contexta ContentFilterContext object passed to each filter
Returnsan iterator containing the content to output
def internal_size_sha_file_byname(name, filters):
Get size and sha of internal content given external content.
Parametersnamepath to file
filtersthe stack of filters to apply
def register_filter_stack_map(name, stack_map_lookup):
Register the filter stacks to use for various preference values.
Parametersnamethe preference/filter-stack name
stack_map_lookupa callable where the parameter is the preference value to match and the result is the matching stack of filters to use, or None if none.
def lazy_register_filter_stack_map(name, module_name, member_name):
Lazily register the filter stacks to use for various preference values.
Parametersnamethe preference/filter-stack name
module_nameThe python path to the module of the filter stack map.
member_nameThe name of the stack_map_lookup callable in the module.
def _get_registered_names():
Get the list of names with filters registered.
def _get_filter_stack_for(preferences):
Get the filter stack given a sequence of preferences.
Parameterspreferencesa sequence of (name,value) tuples where name is the preference name and value is the key into the filter stack map registered for that preference.
def _reset_registry(value=None):

Reset the filter stack registry.

This function is provided to aid testing. The expected usage is:

old = _reset_registry()
# run tests
_reset_registry(old)
Parametersvaluethe value to set the registry to or None for an empty one.
Returnsthe existing value before it reset.
API Documentation for Bazaar, generated by pydoctor at 2019-07-16 00:33:44.