Skip to content

Commit

Permalink
Merge pull request #3057 from jedwards4b/maint-5.6-xml_fixes
Browse files Browse the repository at this point in the history
Fixes an issue in debug code to_string and valid_value list - if valid_value is present but empty this should return an empty list. An empty list in valid_value means that any value is allowed.

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes [CIME Github issue #]

User interface changes?:

Update gh-pages html (Y/N)?:

Code review:
  • Loading branch information
fischer-ncar committed Apr 4, 2019
1 parent ccd7387 commit e0376f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions scripts/lib/CIME/XML/entry_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def get_valid_values(self, vid):

def _get_valid_values(self, node):
valid_values = self.get_element_text("valid_values", root=node)
valid_values_list = None
if valid_values is not None:
valid_values_list = []
if valid_values:
valid_values_list = [item.lstrip() for item in valid_values.split(',')]
return valid_values_list

Expand Down Expand Up @@ -234,7 +234,7 @@ def get_valid_value_string(self, node, value,vid=None, ignore_type=False):
type_str = self._get_type_info(node)
str_value = convert_to_string(value, type_str, vid)

if valid_values is not None and not str_value.startswith('$'):
if valid_values and not str_value.startswith('$'):
expect(str_value in valid_values, "Did not find {} in valid values for {}: {}".format(value, vid, valid_values))
return str_value

Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/CIME/XML/generic_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def set_element_text(self, element_name, new_text, attributes=None, root=None):
return None

def to_string(self, node, method="xml", encoding="us-ascii"):
return ET.tostring(node, method=method, encoding=encoding)
return ET.tostring(node.xml_element, method=method, encoding=encoding)

#
# API for operations over the entire file
Expand Down

0 comments on commit e0376f0

Please sign in to comment.