data_provider

The data_provider module provides a base class for data provider classes. This class provides utility function for the composition of data providers as well as the overriding of get functions.

class parts.data_provider.CombinedProvider(*args)[source]

Bases: parts.data_provider.DataProviderBase

The CombinedProvider allows the combination of multiple data providers. If a get method is requested from the data provider it is forwarded to the combined providers. The lookup is performed in the same order as the providers are provided to the constructor and the first hit is returned.

add(provider)[source]

Add a provider to the combined data provider.

Arguments:

provider: The data provider to add. Must inherit
from DataProviderBase.

Raises:

Exception: If :code: provider argument doesn´t inherit from DataProviderBase.
class parts.data_provider.DataProviderBase[source]

Bases: object

The DataProviderBase implements generic functionality for

  • The overriding of get methods with attributes
  • Composition of data providers

When a data provider inherits from DataProviderBase, the values returned from a get_<attribute> can be overriding simply setting the attribute with the name <attribute> of the object.

The DataProviderBase also allows composing data provider by adding sub- providers to a data provider object. If a simulation queries a get_method from the data provider that the data provider doesn’t provide, the query is forwarded to the subproviders in the order they were added. The get method from the first that provides such a method is returned.

add(subprovider)[source]

Add a subprovider to the data provider.

Arguments:

subprovider: The subprovider to add. Must inherit
from DataProviderBase.

Raises:

Exception: If :code: subprovider argument doesn´t inherit from DataProviderBase.