Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion example_data/example_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"policy:path": "section2/{beta}/{gamma:a}",
"gamma": "#range(3.0, 7.0, 0.5)",
"zeta": "#repeat(@Counter, 4)",
"eta": "$Multiplier * !gamma"
"eta": "$Multiplier * !gamma",
"_psi": 42
}
}
}
2 changes: 2 additions & 0 deletions spawn/specification/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ def _convert_node(self, node):
node_dict['children'] = children
else:
node_dict['path'] = node.path
if node.ghosts:
node_dict['ghosts'] = node.ghosts
return [node_dict]
3 changes: 3 additions & 0 deletions spawn/util/prettyspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
INDENT = ' '

def _prettyspec_impl(spec, indent, outstream):
# pylint: disable=too-many-branches
if spec.get('base_file'):
outstream.write('base_file: {}\n'.format(spec['base_file']))
if 'metadata' in spec:
Expand All @@ -40,6 +41,8 @@ def _prettyspec_impl(spec, indent, outstream):
else:
name = spec['name']
outstream.write('{}{}: {}'.format(INDENT * indent, name, spec['value']))
if spec.get('ghosts'):
outstream.write(' | {}'.format(', '.join('_{}: {}'.format(k, v) for k, v in spec['ghosts'].items())))
if spec.get('path'):
outstream.write(' | path: {}'.format(spec['path']))
outstream.write('\n')
Expand Down
9 changes: 6 additions & 3 deletions tests/specification/converters_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
'notes': 'Some notes',
'spec': {
'policy:path': 'X{alpha}/Y{beta}',
'_casper': 1.0,
'combine:zip': {
'alpha': [3.0, 12.0],
'beta': [0.0, 180.0]
Expand All @@ -161,17 +162,19 @@
{
'path': 'X3.0/Y0.0',
'name': 'beta',
'value': 0.0
'value': 0.0,
'ghosts': {'casper': 1.0}
}
]
},{
}, {
'name': 'alpha',
'value': 12.0,
'children': [
{
'path': 'X12.0/Y180.0',
'name': 'beta',
'value': 180.0
'value': 180.0,
'ghosts': {'casper': 1.0}
}
]
}]
Expand Down