Warning
This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
Source code for galaxy.util.bunch
from .dynamic import HasDynamicProperties
[docs]class Bunch(HasDynamicProperties):
"""
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308
Often we want to just collect a bunch of stuff together, naming each item of
the bunch; a dictionary's OK for that, but a small do-nothing class is even handier, and prettier to use.
"""
def __iter__(self):
return iter(self.__dict__)
def __str__(self):
return f"{self.__dict__}"
def __bool__(self):
return bool(self.__dict__)
__nonzero__ = __bool__
def __setitem__(self, k, v):
self.__dict__.__setitem__(k, v)
def __contains__(self, item):
return item in self.__dict__