From aaa3c4fa01ea0019b4ee721a03662cb32ddd0923 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 20 Feb 2017 15:59:41 +0800 Subject: acispy/manifest.py: Add "has()" method --- acispy/manifest.py | 7 ++++--- 1 file 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] -- cgit v1.2.2