summaryrefslogtreecommitdiff
path: root/ybd/pots.py
diff options
context:
space:
mode:
Diffstat (limited to 'ybd/pots.py')
-rw-r--r--ybd/pots.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/ybd/pots.py b/ybd/pots.py
index 96686ae..07bb644 100644
--- a/ybd/pots.py
+++ b/ybd/pots.py
@@ -54,17 +54,8 @@ class Pots(object):
return self._data.get(dn.get('path', dn.keys()[0]))
def save(self, filename):
-
- # Make a copy, restore any refs which may have been overridden
- # with the sha field while building.
- data = copy.deepcopy(self._data)
- for key, value in data.items():
- if value.get('orig_ref') is not None:
- value['ref'] = value['orig_ref']
- del value['orig_ref']
-
with open(filename, 'w') as f:
- f.write(morph_dump(data, self.defaults))
+ f.write(morph_dump(self._data, self.defaults))
log('CHECK', 'Saved yaml definitions at', filename)
def _load_pots(self, filename):
@@ -80,6 +71,8 @@ class Pots(object):
treefile = os.path.join(config['artifacts'], '.trees')
if not os.path.isfile(treefile):
treefile = os.path.join(config['defdir'], '.trees')
+ if not os.path.isfile(treefile):
+ return
with open(treefile) as f:
text = f.read()
if text:
@@ -88,10 +81,11 @@ class Pots(object):
for path in self._data:
dn = self._data[path]
sha1 = dn.get('sha', dn.get('ref'))
- if sha1 and self._trees.get(path):
- if sha1 == self._trees.get(path)[0]:
- dn['sha'] = self._trees.get(path)[0]
- dn['tree'] = self._trees.get(path)[1]
+ tree_entry = self._trees.get(path)
+ if sha1 and tree_entry:
+ if sha1 == tree_entry[0]:
+ dn['sha'] = tree_entry[0]
+ dn['tree'] = tree_entry[1]
count += 1
log('DEFINITIONS', 'Re-used %s entries from .trees file' % count)
except: