summaryrefslogtreecommitdiff
path: root/morphlib/sourceresolver.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/sourceresolver.py')
-rw-r--r--morphlib/sourceresolver.py36
1 files changed, 8 insertions, 28 deletions
diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py
index 1e64c23a..d2b47d35 100644
--- a/morphlib/sourceresolver.py
+++ b/morphlib/sourceresolver.py
@@ -31,7 +31,7 @@ tree_cache_filename = 'trees.cache.pickle'
buildsystem_cache_size = 10000
buildsystem_cache_filename = 'detected-chunk-buildsystems.cache.pickle'
-supported_versions = [0, 1]
+not_supported_versions = []
class PickleCacheManager(object): # pragma: no cover
'''Cache manager for PyLRU that reads and writes to Pickle files.
@@ -346,29 +346,6 @@ class SourceResolver(object):
loader.set_defaults(morph)
return morph
- def _parse_version_file(self, version_file): # pragma : no cover
- '''Parse VERSION file and return the version of the format if:
-
- VERSION is a YAML file
- 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
-
def _check_version_file(self,definitions_repo,
definitions_absref): # pragma: no cover
version_file = self._get_file_contents(
@@ -377,10 +354,13 @@ class SourceResolver(object):
if version_file is None:
return
- version = self._parse_version_file(version_file)
- if version is not None:
- if version not in supported_versions:
- raise UnknownVersionError(version)
+ try:
+ version = yaml.safe_load(version_file)['version']
+ except (yaml.error.YAMLError, KeyError, TypeError):
+ version = 0
+
+ if version in not_supported_versions:
+ raise UnknownVersionError(version)
def _process_definitions_with_children(self, system_filenames,
definitions_repo,