Properties¶
-
class
NamedProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.common.NamedCommon
A property that takes the name of the class attribute to which it is assigned.
Accepts instance of
pimpmyclass.Config
as configuration values that automatically get populated from kwargs.
-
class
StorageProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.NamedProperty
A property that can store and retrieve information in the instance to which is attached.
Requires that the owner class inherits
pimpmyclass.mixins.StorageMixin
.Notes
The information is stored in uniquely a specified namespace defined by the derived class. Inside that storage, another namespace is specified using the property name.
Derived class should use the dynamically created _store_get and _store_set to retrieve and store information.
Note
Derived classes must override the following variables:
- _storage_ns : str
- Defines a unique namespace under which the information of the derived class is stored.
- _storage_ns_init : callable
- Called upon initialization of the storage to initialize the specific storage of the namespace.
-
class
StatsProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.StorageProperty
A property that keep stats on get and set calls.
Stats can be retrieved with the stat methods and the following keys:
- get
- set
- failed_get
- failed_set
The following statistics are provided in a namedtuple:
- last : float
- most recent duration (seconds).
- count : int
- number of operations.
- mean : float
- average duration per operation (seconds).
- std : float
- standard deviation of the duration (seconds).
- min : float
- shortest duration (seconds).
- max : float
- longest duration (seconds).
Requires that the owner class inherits
pimpmyclass.mixins.StorageMixin
.
-
class
LogProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.NamedProperty
A property that log operations.
Requires that the owner class inherits
pimpmyclass.mixins.LogMixin
.- log_values : (default=True)
- If False, just the types (not the values) will logged.
An obj to str callable can be provided to perform custom serialization.
-
class
LockProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.NamedProperty
A property that with a set or get Lock.
Requires that the owner class inherits
pimpmyclass.mixins.LogMixin
.
-
class
TransformProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.InstanceConfigurableProperty
A property that can transform value before a set operation or after a get operation.
Requires that the owner class inherits
pimpmyclass.mixins.InstanceConfigurableProperty
.Other Parameters: - pre_set (Note: checking function (default=None))
- post_get (Note: checking function (default=None))
-
class
CacheProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.StorageProperty
A property that can store, recall or invalidate a cache.
-
class
GetCacheProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.CacheProperty
A property that stores the get value in the cache.
Requires that the owner class inherits
pimpmyclass.mixins.StorageMixin
.
-
class
SetCacheProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.CacheProperty
A property that stores the set value in the cache.
Requires that the owner class inherits
pimpmyclass.mixins.StorageMixin
.
-
class
PreventUnnecessarySetProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.SetCacheProperty
A property that prevents unnecessary set operations by comparing the value in the cache with the value to be set.
Requires that the owner class inherits
pimpmyclass.mixins.CacheMixin
andpimpmyclass.mixins.LogMixin
.
-
class
ReadOnceProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.InstanceConfigurableProperty
,pimpmyclass.props.GetCacheProperty
Avoids calling the getter if the value is already in the cache.
Other Parameters: read_once (bool (default=False))
-
class
ObservableProperty
(fget=None, fset=None, fdel=None, doc=None, **kwargs)[source]¶ Bases:
pimpmyclass.props.CacheProperty
A property that emits a signal when the cached value is changed (either via set or get)
Requires that the owner class inherits
pimpmyclass.mixins.CacheMixin
andpimpmyclass.mixins.ObservableMixin
.