bexchange.decorators package

Submodules

bexchange.decorators.decorator module

class bexchange.decorators.decorator.decorator(backend, discard_on_none, can_return_invalid_file_content=False)[source]

Bases: object

A decorator is used for modifying a file before it is distributed. Incomming files are not decorated before they are saved. Instead, if that function is wanted a copy-publisher should be used instead.

backend()[source]
Returns:

the backend

can_return_invalid_file_content()[source]

Returns if this decorator can return invalid file content, typically if the decorator modifies a file in some way that it will not pass basic checks like existing sources etc. :return: if this decorator can return invalid file content or not

decorate(ino, meta)[source]

If this decorator decorates the infile, then a new temporary file will be created and returned. :param ino: A tempfile.NamedTemporaryFile instance :returns: A tempfile.NamedTemporaryFile instance

discard_on_none()[source]

Returns if this decorator has been configured to discard file completely when decorator is returning None

class bexchange.decorators.decorator.decorator_manager[source]

Bases: object

The manager for creating decorators used within bexchange. If a class extends the decorator class it can be created by invoking decorator_manager.create(“module….class name”, arguments as a list)

classmethod create(backend, clz, discard_on_none, can_return_invalid_file_content, arguments)[source]

Creates an instance of clz with specified arguments :param clz: class name specified as <module>.<classname> :param discard_on_none: If decorate returns None, then this file should be discarded. :param arguments: a list of arguments that should be used to initialize the class

class bexchange.decorators.decorator.example_filter(backend, discard_on_none, can_return_invalid_file_content, arg1, arg2)[source]

Bases: decorator

decorate(inf, meta)[source]

If this decorator decorates the infile, then a new temporary file will be created and returned. :param ino: A tempfile.NamedTemporaryFile instance :returns: A tempfile.NamedTemporaryFile instance

class bexchange.decorators.decorator.max_age_filter(backend, allow_discard, can_return_invalid_file_content, max_acceptable_age=0, max_acceptable_age_block=0, target_name=None)[source]

Bases: decorator

MAX age filter that will indicate if file should be removed or not. allow_discard is enforced to True since this is a filter.

decorate(inf, meta)[source]

Will use the metadata to know if the file should be filtered or not.

Module contents