diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-08-01 14:10:29 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-08-01 14:29:51 +0900 |
commit | 71e632764963e538f06fff9e830e95cf5d0fc1dc (patch) | |
tree | e0c1423865ed7b1b118f4b5efcfb4dbcceb68543 /pygerrit/__init__.py | |
parent | 37b8b76c49b3f0a5f8a26434f9653b0d3327c7a2 (diff) | |
download | pygerrit-71e632764963e538f06fff9e830e95cf5d0fc1dc.tar.gz |
Add helper methods for initialisation from json data
Added helper methods to initialise model member variables. Now
the models' constructors will not throw exception if a value is
missing, but instead just initialise the variable to None.
Change-Id: I7473ec9bb471f95ea0142067af4750c7e26a0339
Diffstat (limited to 'pygerrit/__init__.py')
-rw-r--r-- | pygerrit/__init__.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pygerrit/__init__.py b/pygerrit/__init__.py index cb77bdc..100380b 100644 --- a/pygerrit/__init__.py +++ b/pygerrit/__init__.py @@ -1,7 +1,13 @@ """ Module to interface with Gerrit. """ -from pygerrit.error import * -from pygerrit.events import * -from pygerrit.models import * -from pygerrit.stream import * +def from_json(json_data, key): + """ Helper method to extract values from JSON data. + + Return the value of `key` from `json_data`, or None if `json_data` + does not contain `key`. + + """ + if key in json_data: + return json_data[key] + return None |