MCPcopy
hub / github.com/opendevops-cn/opendevops / get_closest

Method get_closest

scripts/tornado_source_code/tornado/locale.py:236–251  ·  view source on GitHub ↗

Returns the closest match for the given locale code.

(cls, *locale_codes: str)

Source from the content-addressed store, hash-verified

234
235 @classmethod
236 def get_closest(cls, *locale_codes: str) -> "Locale":
237 """Returns the closest match for the given locale code."""
238 for code in locale_codes:
239 if not code:
240 continue
241 code = code.replace("-", "_")
242 parts = code.split("_")
243 if len(parts) > 2:
244 continue
245 elif len(parts) == 2:
246 code = parts[0].lower() + "_" + parts[1].upper()
247 if code in _supported_locales:
248 return cls.get(code)
249 if parts[0].lower() in _supported_locales:
250 return cls.get(parts[0].lower())
251 return cls.get(_default_locale)
252
253 @classmethod
254 def get(cls, code: str) -> "Locale":

Callers 1

getFunction · 0.80

Calls 4

replaceMethod · 0.80
splitMethod · 0.80
upperMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected