comparison env/lib/python3.9/site-packages/galaxy/util/bunch.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 class Bunch:
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__