summaryrefslogtreecommitdiff
path: root/lib/spack/spack/spec.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/spec.py')
-rw-r--r--lib/spack/spack/spec.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index eaf7544e83..8523dd6838 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1864,6 +1864,15 @@ class Spec(object):
return sjson.dump(self.to_dict(hash), stream)
@staticmethod
+ def from_specfile(path):
+ """Construct a spec from aJSON or YAML spec file path"""
+ with open(path, 'r') as fd:
+ file_content = fd.read()
+ if path.endswith('.json'):
+ return Spec.from_json(file_content)
+ return Spec.from_yaml(file_content)
+
+ @staticmethod
def from_node_dict(node):
spec = Spec()
if 'name' in node.keys():
@@ -3921,7 +3930,7 @@ class Spec(object):
elif 'version' in parts:
col = '@'
- # Finally, write the ouptut
+ # Finally, write the output
write(sig + morph(spec, str(current)), col)
attribute = ''