comparison env/lib/python3.7/site-packages/galaxy/util/bunch.py @ 2:6af9afd405e9 draft

"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author shellac
date Thu, 14 May 2020 14:56:58 -0400
parents 26e78fe6e8c4
children
comparison
equal deleted inserted replaced
1:75ca89e9b81c 2:6af9afd405e9
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__