summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richardipsum@fastmail.co.uk>2015-04-03 16:51:07 +0100
committerBaserock Gerrit <gerrit@baserock.org>2015-04-13 11:46:38 +0000
commitf0a31086d816d0a90fdcfaaa4ea58e122a6d99b3 (patch)
tree62ced6a7a54186c83f4ca881a72e7a80f4b7ad28
parent5925ea129e693346992e8d7d8820a5b8ed7b4903 (diff)
downloadmorph-f0a31086d816d0a90fdcfaaa4ea58e122a6d99b3.tar.gz
_parse_version_file tweak
Swap nested ifs for and Also replace type() with isinstance() Also fix doc string Change-Id: I58177566f19b601bc734f7542c6a5dd52938063a
-rw-r--r--morphlib/sourceresolver.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py
index 7be104d2..771e81e3 100644
--- a/morphlib/sourceresolver.py
+++ b/morphlib/sourceresolver.py
@@ -367,21 +367,19 @@ class SourceResolver(object):
and it's a dict
and has the key 'version'
and the type stored in the 'version' key is an int
- and that int is not in the supported format
otherwise returns None
'''
- version = None
yaml_obj = yaml.safe_load(version_file)
- if yaml_obj is not None:
- if type(yaml_obj) is dict:
- if 'version' in yaml_obj.keys():
- if type(yaml_obj['version']) is int:
- version = yaml_obj['version']
- return version
+ return (yaml_obj['version'] if yaml_obj is not None
+ and isinstance(yaml_obj, dict)
+ and 'version' in yaml_obj
+ and isinstance(yaml_obj['version'], int)
+
+ else None)
def _check_version_file(self, definitions_repo,
definitions_absref): # pragma: no cover