Previous topic

5.3. decomposers — Utilities to decompose a part

Next topic

5.4. exceptions — Exceptions

This Page

Languages

Previous versions

1.2
1.1

5.3.1. decomposers.base — Base classes for decomposers

class plmapp.decomposers.base.DecomposersManager[source]

Bases: object

The DecomposersManager has methods to register a Decomposer (a class helping to decompose a part) and to get a decomposition message that is displayed on the BOM page of a part.

classmethod register(decomposer)[source]

Registers decomposer.

classmethod count()[source]

Returns the number of registered decomposers.

classmethod get_decomposition_message(part)[source]

Returns a decomposition message to decompose part.

Returns an empty string if no decomposer can decompose part.

classmethod is_decomposable(part, msg=False)[source]

Returns True if part is decomposable.

classmethod get_decomposable_parts(part_ids)[source]

Returns all part of part_ids (an iterable of part ids) that are decomposable by the registered decomposers.

class plmapp.decomposers.base.Decomposer(part)[source]

Bases: object

Interface of a decomposer. A decomposer is initialized with a part and has two methods: is_decomposable() and get_message()

The default constructor sets the part attribute with the given part.

is_decomposable(msg=True)[source]

Returns True if the part is decomposable.

get_message()[source]

Returns a message (in html) that is displayed if the part is decomposable.

The returned message should contains a link to decompose the part and should be explicit.

get_decomposable_parts(part_ids)[source]

Returns all part of part_ids (an iterable of part ids) that are decomposable by this decomposer.