made a to_dict for targets. Also a from_dict for sanity

This commit is contained in:
Gregory Becker 2015-11-11 16:16:47 -08:00
parent 8a13d344a8
commit 3067705c10
2 changed files with 21 additions and 2 deletions

View file

@ -69,6 +69,25 @@ def compiler_strategy(self):
else: else:
return "PATH" return "PATH"
def to_dict(self):
print "to_dict"
d = {}
d['name'] = self.name
d['module_name'] = self.module_name
if self.architecture:
d['architecture'] = self.architecture
return d
@staticmethod
def from_dict(d):
print "from_dict"
target = Target.__new__(Target)
target.name = d['name']
target.module_name = d['module_name']
if 'architecture' in d:
target.architecture = d['architecture']
return target
def __str__(self): def __str__(self):
return self.name return self.name

View file

@ -651,7 +651,7 @@ def to_node_dict(self):
d = { d = {
'variants' : dict( 'variants' : dict(
(name,v.enabled) for name, v in self.variants.items()), (name,v.enabled) for name, v in self.variants.items()),
'arch' : self.architecture, 'arch' : self.architecture.to_dict(),
'dependencies' : dict((d, self.dependencies[d].dag_hash()) 'dependencies' : dict((d, self.dependencies[d].dag_hash())
for d in sorted(self.dependencies)) for d in sorted(self.dependencies))
} }
@ -680,7 +680,7 @@ def from_node_dict(node):
spec = Spec(name) spec = Spec(name)
spec.versions = VersionList.from_dict(node) spec.versions = VersionList.from_dict(node)
spec.architecture = node['arch'] spec.architecture = spack.architecture.Target.from_dict(node['arch'])
if node['compiler'] is None: if node['compiler'] is None:
spec.compiler = None spec.compiler = None