Source code for sardine.acquisition.waits

[docs] class Waits: def __init__(self): self._waits = {} def _has_waits(self): ''' Returns True if there are values in the waits, False if there are none ''' if any(self._waits.values()): return True return False
[docs] def add_dependencies(self, for_action, *dependencies): ''' Exists if there are no dependencies Sets as default wait the given action Updates the action with the set of given dependencies ''' if not dependencies: return self._waits.setdefault(for_action, set()) self._waits[for_action].update(set(dependencies))
[docs] def mark_dependencies_met(self, *dependencies_met): ''' Exists if there are no waits or no dependencies Creates a set with the given dependencies Creates new waits by removing the ones with dependencies ''' if not self._has_waits() or not dependencies_met: return set_to_remove = set(dependencies_met) new_waits = {} for k, v in self._waits.items(): new_waits[k] = v.difference_update(set_to_remove)
[docs] def exists(self, for_action): ''' Returns True if there is the given action, False if there is not (??) ''' if self._waits.get(for_action, False): return True return False
def __bool__(self): ''' Returns True if there are waits, False if there are none ''' if self._has_waits(): return True return False