diff options
author | Richard Ipsum <richardipsum@fastmail.co.uk> | 2015-04-03 16:51:07 +0100 |
---|---|---|
committer | Baserock Gerrit <gerrit@baserock.org> | 2015-04-13 11:46:38 +0000 |
commit | f0a31086d816d0a90fdcfaaa4ea58e122a6d99b3 (patch) | |
tree | 62ced6a7a54186c83f4ca881a72e7a80f4b7ad28 /morphlib/sourceresolver.py | |
parent | 5925ea129e693346992e8d7d8820a5b8ed7b4903 (diff) | |
download | morph-f0a31086d816d0a90fdcfaaa4ea58e122a6d99b3.tar.gz |
_parse_version_file tweak
Swap nested ifs for and
Also replace type() with isinstance()
Also fix doc string
Change-Id: I58177566f19b601bc734f7542c6a5dd52938063a
Diffstat (limited to 'morphlib/sourceresolver.py')
-rw-r--r-- | morphlib/sourceresolver.py | 14 |
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 |