diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-11 13:29:20 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-11 13:29:20 +0800 |
commit | 50259703f19bdec23cfa2b9f07098661a928c370 (patch) | |
tree | b85eb304a50d1917075c2c602f47a2ca7b79c5b3 | |
parent | 436455f8a8ec5fa83b8f164cbc28d0f734a69c06 (diff) | |
download | chandra-acis-analysis-50259703f19bdec23cfa2b9f07098661a928c370.tar.bz2 |
manifest.py: Handle empty manifest file
-rwxr-xr-x | scripts/manifest.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/manifest.py b/scripts/manifest.py index 2bdb862..bee8e5c 100755 --- a/scripts/manifest.py +++ b/scripts/manifest.py @@ -31,6 +31,8 @@ class Manifest: self.filepath = filepath self.manifest = ruamel.yaml.load( open(filepath), Loader=ruamel.yaml.RoundTripLoader) + if self.manifest is None: + self.manifest = ruamel.yaml.comments.CommentedMap() def save(self): with open(self.filepath, "w") as f: @@ -43,9 +45,9 @@ class Manifest: If the specified item doesn't exist, raise a ``KeyError``. """ - try: + if key in self.manifest: return self.manifest[key] - except KeyError: + else: raise KeyError("manifest doesn't have item: '%s'" % key) def set(self, key, value): |