anyconfig.processors.processors

A collection of models.processor.Processor and children classes.

class anyconfig.processors.processors.Processors(processors=None)

Bases: object

An abstract class of which instance holding processors.

register(pcls)

Register processor or its children class objects.

Return type:

None

load_plugins()

Load and register pluggable processor classes internally.

Return type:

None

list(*, sort=False)

List processors.

Parameters:

sort (bool) – Result will be sorted if it’s True

Return type:

list[type[TypeVar(ProcT, bound= Processor)]]

Returns:

A list of Processor or its children classes

list_by_cid()

List processors by those IDs.

Return type:

list[tuple[str, list[TypeVar(ProcT, bound= Processor)]]]

Returns:

A list of Processor or its children classes grouped by each cid, [(cid, [Processor)]]

list_by_type()

List processors by those types.

Return type:

list[tuple[str, list[TypeVar(ProcT, bound= Processor)]]]

Returns:

A list of Processor or its children classes grouped by each type, [(type, [Processor)]]

list_by_x(item=None)

List processors by those factor ‘x’.

Parameters:

item (Optional[str]) – Grouping key, one of ‘cid’, ‘type’ and ‘extensions’

Return type:

list[tuple[str, list[TypeVar(ProcT, bound= Processor)]]]

Returns:

A list of Processor or its children classes grouped by given ‘item’, [(cid, [Processor)]] by default

list_x(key=None)

List the factor ‘x’ of processors.

Parameters:

key (Optional[str]) – Which of key to return from ‘cid’, ‘type’, and ‘extention’

Return type:

list[str]

Returns:

A list of x ‘key’

findall(obj, forced_type=None)

Find all of the processors match with tthe given conditions.

Parameters:
  • obj (Union[str, Path, IO, IOInfo, None]) – a file path, file, file-like object, pathlib.Path object or an ‘anyconfig.ioinfo.IOInfo’ (namedtuple) object

  • forced_type (Optional[str]) – Forced processor type to find

Return type:

list[TypeVar(ProcT, bound= Processor)]

Returns:

A list of instances of processor classes to process ‘obj’

Raises:

ValueError, UnknownProcessorTypeError, UnknownFileTypeError

find(obj, forced_type=None)

Find the processor best match with tthe given conditions.

Parameters:
  • obj (Union[str, Path, IO, IOInfo, None]) – a file path, file, file-like object, pathlib.Path object or an ‘anyconfig.ioinfo.IOInfo’ (namedtuple) object

  • forced_type (Union[str, TypeVar(ProcT, bound= Processor), type[TypeVar(ProcT, bound= Processor)], None]) – Forced processor type to find or a processor class object or a processor intance

Return type:

TypeVar(ProcT, bound= Processor)

Returns:

an instance of processor class to process ‘obj’

Raises:

ValueError, UnknownProcessorTypeError, UnknownFileTypeError