def test_to_record_dict(mock_packages, config): specs = ['mpileaks', 'zmpi', 'dttop'] for name in specs: spec = Spec(name).concretized() record = spec.to_record_dict() assert record["name"] == name assert "hash" in record node = spec.to_node_dict() for key, value in node[name].items(): assert key in record assert record[key] == value
def display_specs_as_json(specs, deps=False): """Convert specs to a list of json records.""" seen = set() records = [] for spec in specs: if spec.dag_hash() in seen: continue seen.add(spec.dag_hash()) records.append(spec.to_node_dict()) if deps: for dep in spec.traverse(): if dep.dag_hash() in seen: continue seen.add(dep.dag_hash()) records.append(dep.to_node_dict()) sjson.dump(records, sys.stdout)