from common.constants.region import UserRegion class RegionHandler: def __init__(self): self._zh_cn_patterns = [".cn", "cn.", "host"] def detect_from_host(self, host: str) -> UserRegion: # Now we set user preferred region based on host for parttern in self._zh_cn_patterns: if parttern in host.lower(): return UserRegion.ZH_CN return UserRegion.OTHER