build_emoji: Refactor `get_emoji_code()` to not fail for old datasources.

If `non_qualified` field is not present then return the value of
`unified` field instead of failing.
This commit is contained in:
Harshit Bansal 2018-08-26 12:26:18 +00:00 committed by Tim Abbott
parent ec2ebd1cc9
commit dbc3774c2f
1 changed files with 3 additions and 1 deletions

View File

@ -63,7 +63,9 @@ def get_emoji_code(emoji_dict: Dict[str, Any]) -> str:
# should have a colorful display. Hence we can continue using emoji characters # should have a colorful display. Hence we can continue using emoji characters
# without appending emoji presentation selector. # without appending emoji presentation selector.
# (http://unicode.org/reports/tr51/index.html#Presentation_Style) # (http://unicode.org/reports/tr51/index.html#Presentation_Style)
emoji_code = emoji_dict["non_qualified"] or emoji_dict["unified"] # If `non_qualified` field is present and not None return it otherwise
# return `unified` field.
emoji_code = emoji_dict.get("non_qualified") or emoji_dict["unified"]
return emoji_code.lower() return emoji_code.lower()
# Returns a dict from categories to list of codepoints. The list of # Returns a dict from categories to list of codepoints. The list of