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

Merged changes from trunk

* r3545: Changed to parse namelist section comments for example key assignments.
parent 7f3b2b16
No related branches found
No related tags found
No related merge requests found
...@@ -146,11 +146,11 @@ def format_namelist(section): ...@@ -146,11 +146,11 @@ def format_namelist(section):
lines = StringIO.StringIO() lines = StringIO.StringIO()
for group, contents in section.iteritems(): for group, contents in section.iteritems():
if isinstance(contents, dict): if isinstance(contents, dict):
group = group.lower() group_id = group.lower()
if not any(map(lambda x: re.match(x, group), black_list)): if not any(map(lambda x: re.match(x, group_id), black_list)):
# Create list of removed keys # Create list of removed keys
remove_keys = cut_remove_list(contents, '.remove') remove_keys = cut_remove_list(contents, '.remove')
group_name = re.sub(r' .*$', '', group) group_name = re.sub(r' .*$', '', group_id)
lines.write('&'+group_name+'\n') lines.write('&'+group_name+'\n')
for key, value in contents.iteritems(): for key, value in contents.iteritems():
if key not in remove_keys: if key not in remove_keys:
...@@ -166,6 +166,10 @@ def format_namelist(section): ...@@ -166,6 +166,10 @@ def format_namelist(section):
line = re.sub(r'^#', ' !', line) line = re.sub(r'^#', ' !', line)
lines.write(' '*base_indent+key+' = '+ lines.write(' '*base_indent+key+' = '+
format_value(value, indent)+line+'\n') format_value(value, indent)+line+'\n')
for line in section.comments.get(group, []):
if line and re.match(r'#\s*\w+\s*=', line):
lines.write(' '*base_indent+
re.sub(r'^#', '!', line)+'\n')
lines.write('/\n') lines.write('/\n')
return lines.getvalue() return lines.getvalue()
......
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