EnkaNetwork.py/enkanetwork/config.py

31 lines
798 B
Python
Raw Permalink Normal View History

from typing import (
ClassVar
)
from .utils import get_user_agent
2023-02-16 18:05:15 +00:00
from .cache import Cache, StaticCache
class Config:
# HTTP Config
ENKA_PROTOCOL: ClassVar[str] = "https"
2023-02-07 08:22:05 +00:00
ENKA_URL: ClassVar[str] = "enka.network"
# Assets
ASSETS_PROTOCOL: ClassVar[str] = "https"
ASSETS_URL: ClassVar[str] = "raw.githubusercontent.com"
# Header Config
USER_AGENT: ClassVar[str] = get_user_agent()
# Client config
CACHE_ENABLED: ClassVar[bool] = True
2023-02-16 18:05:15 +00:00
CACHE: ClassVar[Cache] = StaticCache(1024, 60 * 3)
@classmethod
def init_cache(
cls,
cache: Cache,
enabled: bool = True
):
cls.CACHE = cache
cls.CACHE_ENABLED = enabled
@classmethod
def init_user_agent(cls, agent: str):
cls.USER_AGENT = agent