Skip to content

Commit

Permalink
aligned common/mixin.py with original
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbarring committed May 11, 2023
1 parent 94a1121 commit 6d2da8c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/iris/common/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""


from collections.abc import Mapping
from functools import wraps

Expand All @@ -24,6 +23,7 @@
def _get_valid_standard_name(name):
# Standard names are optionally followed by a standard name
# modifier, separated by one or more blank spaces

if name is not None:
# Supported standard name modifiers. Ref: [CF] Appendix C.
valid_std_name_modifiers = [
Expand All @@ -35,21 +35,24 @@ def _get_valid_standard_name(name):

name_groups = name.split(maxsplit=1)
if name_groups:
std_name = check_valid_std_name(name_groups[0])
std_name = name_groups[0]
try:
new_std_name = check_valid_std_name(name_groups[0])
name = name.replace(std_name, new_std_name)
except ValueError:
raise ValueError(
"{!r} is not a valid standard_name".format(name)
)
try:
std_name_modifier = name_groups[1]
except IndexError:
result = std_name
pass # No modifier
else:
if std_name_modifier in valid_std_name_modifiers:
result = f"{std_name} {std_name_modifier}"
else:
if std_name_modifier not in valid_std_name_modifiers:
raise ValueError(
f"{repr(std_name_modifier)} is not a valid standard_name"
"{!r} is not a valid standard_name".format(name)
)
else:
result = None
return result
return name


class LimitedAttributeDict(dict):
Expand Down

0 comments on commit 6d2da8c

Please sign in to comment.