Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, settings):
_defaults = get_default_config()
globals_ = settings.get("global", _defaults["global"])
self.__version_from_match = globals_.get("version_from_match", _defaults["global"]["version_from_match"]) # Valid json values are: "version", "patch", and null
self.__default_region = globals_.get("default_region", _defaults["global"]["default_region"])
if self.__default_region is not None:
self.__default_region = Region(self.__default_region.upper())
self.__plugins = settings.get("plugins", _defaults["plugins"])
self.__pipeline_args = settings.get("pipeline", _defaults["pipeline"])
self.__pipeline = None # type: DataPipeline
logging_config = settings.get("logging", _defaults["logging"])
self.__default_print_calls = logging_config.get("print_calls", _defaults["logging"]["print_calls"])
self.__default_print_riot_api_key = logging_config.get("print_riot_api_key", _defaults["logging"]["print_riot_api_key"])
for name in ["default", "core"]:
logger = logging.getLogger(name)
level = logging_config.get(name, _defaults["logging"][name])
logger.setLevel(level)
for handler in logger.handlers:
handler.setLevel(level)
DEFAULT_LOCALE = {
Region.brazil: "pt_BR",
Platform.brazil: "pt_BR",
Region.europe_north_east: "en_GB",
Platform.europe_north_east: "en_GB",
Region.europe_west: "en_GB",
Platform.europe_west: "en_GB",
Region.japan: "ja_JP",
Platform.japan: "ja_JP",
Region.korea: "ko_KR",
Platform.korea: "ko_KR",
Region.latin_america_north: "es_MX",
Platform.latin_america_north: "es_MX",
Region.latin_america_south: "es_AR",
Platform.latin_america_south: "es_AR",
Region.north_america: "en_US",
Platform.north_america: "en_US",
Region.oceania: "en_AU",
Platform.oceania: "en_AU",
Region.turkey: "tr_TR",
Platform.turkey: "tr_TR",
Region.russia: "ru_RU",
Platform.russia: "ru_RU",
}
class Key(Enum):
Q = "Q"
W = "W"
E = "E"
def __init__(self, *, id: int = None, name: str = None, region: Union[Region, str] = None, version: str = None, locale: str = None, included_data: Set[str] = None):
if included_data is None:
included_data = {"all"}
if locale is None and region is not None:
locale = Region(region).default_locale
kwargs = {"region": region, "included_data": included_data, "locale": locale}
if id is not None:
kwargs["id"] = id
if name is not None:
kwargs["name"] = name
if version is not None:
kwargs["version"] = version
super().__init__(**kwargs)
def __init__(self, *args, region: Union[Region, str] = None, version: str = None, locale: str = None, included_data: Set[str] = None):
if region is None:
region = configuration.settings.default_region
if region is not None and not isinstance(region, Region):
region = Region(region)
if included_data is None:
included_data = {"all"}
if locale is None:
locale = region.default_locale
kwargs = {"region": region, "included_data": included_data, "locale": locale}
if version:
kwargs["version"] = version
super().__init__(*args, **kwargs)
def put_item_list(self, item: ItemListDto, context: PipelineContext = None) -> None:
platform = Region(item["region"]).platform.value
included_data = "|".join(sorted(item["includedData"]))
key = "{clsname}.{platform}.{version}.{locale}.{included_data}".format(clsname=ItemListDto.__name__,
platform=platform,
version=item["version"],
locale=item["locale"],
included_data=included_data)
self._put(key, item)
self.clear()
from ..transformers.runes import RunesTransformer
SearchableList.__init__(self, [RunesTransformer.rune_page_data_to_core(None, i) for i in data])
super().__load_hook__(load_group, data)
@lazy_property
def region(self) -> Region:
return Region(self._data[RunePagesData].region)
@lazy_property
def platform(self) -> Platform:
return self.region.platform
@searchable({str: ["name", "runes", "region", "platform", "locale"], int: ["id"], bool: ["current"], StaticdataRune: ["runes"], Region: ["region"], Platform: ["platform"]})
class RunePage(CassiopeiaGhost):
_data_types = {RunePageData}
_load_types = {RunePageData: RunePages}
@lazy_property
def region(self) -> Region:
return Region(self._data[RunePageData].region)
@lazy_property
def platform(self) -> Platform:
"""The platform for this rune page."""
return self.region.platform
@property
def locale(self) -> str:
"""The locale for this rune page."""
def put_timeline(self, item: TimelineDto, context: PipelineContext = None) -> None:
platform = Region(item["region"]).platform.value
key = "{clsname}.{platform}.{id}".format(clsname=TimelineDto.__name__,
platform=platform,
id=item["matchId"])
self._put(key, item)
def __init__(self, *, id: int, patch: Patch, included_data: Set[str] = None, elo: Set[str] = None, region: Union[Region, str] = None):
if region is None:
region = settings.default_region
if not isinstance(region, Region):
region = Region(region)
if included_data is None:
# I manually chose a selection of data to return by default; I chose this data because it's relatively small and provides some additional useful information.
included_data = "kda,damage,minions,wards,overallPerformanceScore,goldEarned"
if elo is None:
elo = "PLATINUM,DIAMOND,MASTER,CHALLENGER"
kwargs = {"region": region, "id": id, "patch": patch._patch, "elo": elo, "included_data": included_data}
super().__init__(**kwargs)
def put_mastery_pages(self, item: MasteryPagesDto, context: PipelineContext = None) -> None:
platform = Region(item["region"]).platform.value
key = "{clsname}.{platform}.{id}".format(clsname=MasteryPagesDto.__name__,
platform=platform,
id=item["summonerId"])
self._put(key, item)
def __init__(self, *, strings: Dict[str, str] = None, region: Union[Region, str] = None, version: str = None, locale: str = None):
if locale is None and region is not None:
locale = Region(region).default_locale
kwargs = {"region": region, "locale": locale}
if version is not None:
kwargs["version"] = version
if strings is not None:
kwargs["strings"] = strings
super().__init__(**kwargs)