comparison env/lib/python3.7/site-packages/galaxy/util/bunch.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
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__