Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/galaxy/util/bunch.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:32:28 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d30785e31577 | 1:56ad4e20f292 |
---|---|
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__ |