Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/galaxy/util/bunch.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 class Bunch(object): | |
| 2 """ | |
| 3 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 | |
| 4 | |
| 5 Often we want to just collect a bunch of stuff together, naming each item of | |
| 6 the bunch; a dictionary's OK for that, but a small do-nothing class is even handier, and prettier to use. | |
| 7 """ | |
| 8 | |
| 9 def __init__(self, **kwds): | |
| 10 self.__dict__.update(kwds) | |
| 11 | |
| 12 def dict(self): | |
| 13 return self.__dict__ | |
| 14 | |
| 15 def get(self, key, default=None): | |
| 16 return self.__dict__.get(key, default) | |
| 17 | |
| 18 def __iter__(self): | |
| 19 return iter(self.__dict__) | |
| 20 | |
| 21 def items(self): | |
| 22 return self.__dict__.items() | |
| 23 | |
| 24 def keys(self): | |
| 25 return self.__dict__.keys() | |
| 26 | |
| 27 def values(self): | |
| 28 return self.__dict__.values() | |
| 29 | |
| 30 def __str__(self): | |
| 31 return '%s' % self.__dict__ | |
| 32 | |
| 33 def __bool__(self): | |
| 34 return bool(self.__dict__) | |
| 35 __nonzero__ = __bool__ | |
| 36 | |
| 37 def __setitem__(self, k, v): | |
| 38 self.__dict__.__setitem__(k, v) | |
| 39 | |
| 40 def __contains__(self, item): | |
| 41 return item in self.__dict__ |
