diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-20 15:59:41 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-20 18:28:20 +0800 |
commit | aaa3c4fa01ea0019b4ee721a03662cb32ddd0923 (patch) | |
tree | 706d20f099f99a321e7258c162c5892d005dddf7 /acispy | |
parent | 2d587000f7f77c3b59c9254623604ba3ac9554e5 (diff) | |
download | chandra-acis-analysis-aaa3c4fa01ea0019b4ee721a03662cb32ddd0923.tar.bz2 |
acispy/manifest.py: Add "has()" method
Diffstat (limited to 'acispy')
-rw-r--r-- | acispy/manifest.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/acispy/manifest.py b/acispy/manifest.py index 099c0f9..d111d94 100644 --- a/acispy/manifest.py +++ b/acispy/manifest.py @@ -45,6 +45,9 @@ class Manifest: def show(self): print(self.dump()) + def has(self, key): + return True if key in self.manifest else False + def get(self, key): """ Get the value of the specified item in the manifest. @@ -59,7 +62,7 @@ class Manifest: KeyError : If the specified item doesn't exist. """ - if key in self.manifest: + if self.has(key): return self.manifest[key] else: raise KeyError("manifest doesn't have item: '%s'" % key) @@ -68,8 +71,6 @@ class Manifest: """ Get the value of the specified item in the manifest. - TODO: splitlist - Parameters ---------- keys : list[str] |