def execute(self, maybe_code): if isinstance(maybe_code, dict): maybe_code = maybe_code['#text'] # Force indices to populate if not languages._is_loaded: languages._load() for kwarg in languages.indices.keys(): try: return languages.get(**{kwarg: maybe_code}).iso639_3_code except KeyError: continue return None