diff options
author | Paul Sherwood <paul.sherwood@codethink.co.uk> | 2016-06-19 10:45:52 +0100 |
---|---|---|
committer | Paul Sherwood <paul.sherwood@codethink.co.uk> | 2016-06-19 17:34:13 +0100 |
commit | 098063fdf8577f2cf85a4c65315f9c82d0528f43 (patch) | |
tree | 5b42df3a2c797b4bd7a79a5d4446a25d868bc433 | |
parent | c43828d6f8dba6f3a76e62e57f910145e25dea59 (diff) | |
download | ybd-098063fdf8577f2cf85a4c65315f9c82d0528f43.tar.gz |
No need for check_trees function, so remove it
Previously we only used the .trees file if nothing had changed
but actually, if we have the tree for a given SHA, we can always
use it. So cache-key calculation will be faster, since it can use
previously found trees more often.
-rw-r--r-- | ybd/definitions.py | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/ybd/definitions.py b/ybd/definitions.py index 70117a1..f66913b 100644 --- a/ybd/definitions.py +++ b/ybd/definitions.py @@ -32,8 +32,7 @@ class Definitions(object): self.defaults = Defaults() config['cpu'] = self.defaults.cpus.get(config['arch'], config['arch']) self.parse_files(directory) - if self._check_trees(): - self._set_trees() + self._set_trees() def parse_files(self, directory): schemas = self.load_schemas() @@ -234,31 +233,11 @@ class Definitions(object): path = path.rpartition('.morph')[0] return path - def _check_trees(self): - '''True if the .trees file matches the current working subdirectories - - The .trees file lists all git trees for a set of definitions, and a - checksum of the checked-out subdirectories when we calculated them. - - If the checksum for the current subdirectories matches, return True - - ''' - try: - with chdir(config['defdir']): - checksum = check_output('ls -lRA */', shell=True) - checksum = hashlib.md5(checksum).hexdigest() - with open('.trees') as f: - text = f.read() - self._trees = yaml.safe_load(text) - if self._trees.get('.checksum') == checksum: - return True - except: - self._trees = {} - - return False - def _set_trees(self): '''Use the tree values from .trees file, to save time''' + with open('.trees') as f: + text = f.read() + self._trees = yaml.safe_load(text) for path in self._data: try: dn = self._data[path] |