Added hashes to the database
This commit is contained in:
parent
1da56e5290
commit
55f68bb2b0
1 changed files with 19 additions and 12 deletions
|
@ -48,6 +48,10 @@ def __init__(self,file_name="specDB.yaml"):
|
||||||
"""
|
"""
|
||||||
Create an empty Database
|
Create an empty Database
|
||||||
Location defaults to root/specDB.yaml
|
Location defaults to root/specDB.yaml
|
||||||
|
The individual data are dicts containing
|
||||||
|
spec: the top level spec of a package
|
||||||
|
path: the path to the install of that package
|
||||||
|
dep_hash: a hash of the dependence DAG for that package
|
||||||
"""
|
"""
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
self.data = []
|
self.data = []
|
||||||
|
@ -69,7 +73,8 @@ def from_yaml(self,stream):
|
||||||
for sp in file['database']:
|
for sp in file['database']:
|
||||||
spec = Spec.from_node_dict(sp['spec'])
|
spec = Spec.from_node_dict(sp['spec'])
|
||||||
path = sp['path']
|
path = sp['path']
|
||||||
db_entry = {'spec': spec, 'path': path}
|
dep_hash = sp['hash']
|
||||||
|
db_entry = {'spec': spec, 'path': path, 'hash':dep_hash}
|
||||||
self.data.append(db_entry)
|
self.data.append(db_entry)
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +102,8 @@ def write_database_to_yaml(self,stream):
|
||||||
for sp in self.data:
|
for sp in self.data:
|
||||||
node = {}
|
node = {}
|
||||||
node['spec']=Spec.to_node_dict(sp['spec'])
|
node['spec']=Spec.to_node_dict(sp['spec'])
|
||||||
node['spec'][sp['spec'].name]['hash']=sp['spec'].dag_hash()
|
# node['spec'][sp['spec'].name]['hash']=sp['spec'].dag_hash()
|
||||||
|
node['hash']=sp['hash']
|
||||||
node['path']=sp['path']
|
node['path']=sp['path']
|
||||||
node_list.append(node)
|
node_list.append(node)
|
||||||
return yaml.dump({ 'database' : node_list},
|
return yaml.dump({ 'database' : node_list},
|
||||||
|
@ -122,11 +128,12 @@ def add(root, spec, path):
|
||||||
"""
|
"""
|
||||||
database = Database.read_database(root)
|
database = Database.read_database(root)
|
||||||
|
|
||||||
spec_and_path = {}
|
sph = {}
|
||||||
spec_and_path['spec']=spec
|
sph['spec']=spec
|
||||||
spec_and_path['path']=path
|
sph['path']=path
|
||||||
|
sph['hash']=spec.dag_hash()
|
||||||
|
|
||||||
database.data.append(spec_and_path)
|
database.data.append(sph)
|
||||||
|
|
||||||
database.write(root)
|
database.write(root)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue