StateManager Class

Manages state for any hashable object.

When tracking multiple files and their chunks, each file/chunk can be in any valid state for that particular type.

At the simplest level, we need to set and retrieve an object's current state, while only allowing valid states to be used. In addition, we also need to give statistics about a group of objects (are all objects in one state? how many objects are in each available state?).

Inheritance
builtins.object
StateManager

Constructor

StateManager(*states)

Parameters

states
<xref:<xref:list of valid states>>
Required

Managed objects can only use these defined states.

Examples


>>> StateManager('draft', 'review', 'complete')  
<StateManager: draft=0 review=0 complete=0>
>>> mgr = StateManager('off', 'on')
>>> mgr['foo'] = 'on'
>>> mgr['bar'] = 'off'
>>> mgr['quux'] = 'on'
>>> mgr  
<StateManager: off=1 on=2>
>>> mgr.contains_all('on')
False
>>> mgr['bar'] = 'on'
>>> mgr.contains_all('on')
True
>>> mgr.contains_none('off')
True

Internal class used by ADLTransferClient.

Methods

contains_all

Return whether all managed objects are in the given state

contains_none

Return whether no managed objects are in the given states

contains_all

Return whether all managed objects are in the given state

contains_all(state)

Parameters

state
Required

contains_none

Return whether no managed objects are in the given states

contains_none(*states)

Attributes

objects

states