Last active
January 19, 2016 22:51
-
-
Save optilude/127ea0259324c0e7b41d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def resolve_field_value(self, issue, field_name): | |
field_value = getattr(issue.fields, field_name) | |
if field_value is None: | |
return None | |
value = getattr(field_value, 'value', field_value) | |
if isinstance(value, (list, tuple)): | |
if len(value) == 0: | |
value = None | |
else: | |
values = [getattr(v, 'name', v) for v in value] | |
if field_name not in self.settings['konwn_values']: | |
value = values[0] | |
else: | |
try: | |
value = next(itertools.ifilter(lambda v: v in values, self.settings['known_values'][field_name])) | |
except StopIteration: | |
value = None | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment