aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/git/modifier.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2012-03-15 22:08:50 +0100
committerGuido Günther <agx@sigxcpu.org>2012-03-15 22:38:32 +0100
commita6bca603b9f3852a784afc76ea1d0a24306f3672 (patch)
tree76559a138b2af9ff334a9525cedb9702cd7b6eb3 /gbp/git/modifier.py
parent797a229ff721d2d831e6c08b06c3eea272c4dc2b (diff)
GitModifier: add __getitem__ and keys()
so it can be used as dictonary
Diffstat (limited to 'gbp/git/modifier.py')
-rw-r--r--gbp/git/modifier.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/gbp/git/modifier.py b/gbp/git/modifier.py
index c77bb4d1..51d9693b 100644
--- a/gbp/git/modifier.py
+++ b/gbp/git/modifier.py
@@ -76,3 +76,19 @@ class GitModifier(object):
"""
return self._get_env('committer')
+ def __getitem__(self, key):
+ if key in self.keys():
+ return self.__dict__[key]
+ else:
+ raise KeyError
+
+ def keys(self):
+ return [ 'name', 'email', 'date' ]
+
+ def items(self):
+ items = []
+ for key in self.keys():
+ val = self.__dict__[key]
+ if val:
+ items.append((key, val))
+ return items