Skip to content
Snippets Groups Projects
Commit 9103774c authored by Karl-Hermann Wieners's avatar Karl-Hermann Wieners
Browse files

Prepared for release 0.3.3

* Added 'raw(...)' expression to allow unquoted namelist expressions
* Added 'set' test to reliably check if namelist switches are true
* Updated version info and change list
parent c1977e37
No related branches found
Tags mkexp-0.3.2
No related merge requests found
......@@ -6,6 +6,20 @@ Make Experiments!
Release Changes
---------------
Release 0.3.3
=============
Configuration
-------------
* Added 'raw(...)' expression to allow unquoted namelist expressions.
Needed for native variables containing lists
Templates
---------
* Added 'set' test to reliably check if namelist switches are true
Release 0.3.2
=============
......
......@@ -90,9 +90,11 @@ def move_file_to_backup(file_name, backup_name):
# Namelist formatting
quote = repr
def format_atom(value):
'''Format atomic value for use in namelists'''
result = repr(value)
result = quote(value)
# Strip quotes from all-numeric strings
result = re.sub('^(["'r"'])([-+]?(\d+\.\d*|\.?\d+)([de][-+]?\d+)?)\1$", r'\2',
result, flags=re.I)
......@@ -102,6 +104,7 @@ def format_atom(value):
result = re.sub('^(["'r"'])\.?t(rue)?\.?\1$", '.true.', result, flags=re.I)
result = \
re.sub('^(["'r"'])\.?f(alse)?\.?\1$", '.false.', result, flags=re.I)
result = re.sub('^(["'r"'])raw\((.*)\)\1$", r'\2', result)
return result
def format_value(value, indent):
......@@ -208,9 +211,6 @@ def format_vars(section, key, log, fmt):
# Format all list elements
section[newkey] = map(transform, value)
def quote(value):
return repr(value)
# Command line parsing
def value_to_list(value):
......@@ -313,6 +313,10 @@ template_env.filters['split'] = lambda x, s, m=-1: x.split(s, m)
# - Add list operations filter and map
template_env.filters['filter'] = lambda x, f=None: filter(f, x)
# Additional tests
# - Check a namelist logical
template_env.tests['set'] = lambda x: x.strip('.').lower().startswith('t')
# Read and store configuration info from input and experiments' library
# Store environment as default for control settings, then add config from files
......
from distutils.core import setup
name = 'mkexp'
version = '0.3.2'
version = '0.3.3'
setup(
name = name,
......
......@@ -234,6 +234,39 @@ class ContentTestCase(MkexpTestCase):
result = align(result)
self.assertMultiLineEqual(expected, result)
def test_var_in_namelist(self):
exp_id = "test_var_in_namelist"
job_id = "job"
writeconfig(exp_id, """
EXP_TYPE =
[namelists]
[[namelist]]
[[[group]]]
var_1 = raw($$value_1)
var_2 = raw($${value_2})
var_3 = a, raw($$value_3), b
var_4 = a$$value_4
var_5 = $${value_5}b
[jobs]
[["""+job_id+"""]]
""")
writetemplate(exp_id, job_id, """
%{NAMELIST}
""")
expected = align("""
&group
var_1 = $value_1
var_2 = ${value_2}
var_3 = 'a', $value_3, 'b'
var_4 = 'a$value_4'
var_5 = '${value_5}b'
/
""")
ignore = output(script("mkexp "+exp_id+".config"))
result = readfile(join("test", "experiments", exp_id, exp_id+"."+job_id))
result = align(result)
self.assertMultiLineEqual(expected, result)
def test_split_date(self):
exp_id = 'test_split_date'
job_id = 'job'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment