Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_name(self, attribute: str, language, min_score: int):
assert attribute in self.ATTRIBUTES
if isinstance(language, Language):
language = language.to_tag()
attr_value = getattr(self, attribute)
if attr_value is None:
return None
names = code_to_names(attribute, attr_value)
names['und'] = getattr(self, attribute)
return self._best_name(names, language, min_score)
def variant_names(self, language=DEFAULT_LANGUAGE, min_score: int=75) -> list:
"""
Describe each of the variant parts of the language tag in a natural
language.
"""
names = []
for variant in self.variants:
var_names = code_to_names('variant', variant)
names.append(self._best_name(var_names, language, min_score))
return names