"Int16", "Int32", "Int64", "UInt8", "UInt16", "UInt32", "UInt64", "String", "Type", ) ORDER = {"big": ">", "little": "<"} DEFAULT_ORDER = "little" GAMEMODE_STATE = ("Cube", "Ship", "UFO", "Ball", "Wave", "Robot", "Spider") NULL_BYTE = b"\x00" T = TypeVar("T") def read_until_terminator(data: bytes, terminator: int = 0) -> bytes: return bytes(itertools.takewhile(lambda char: char != terminator, data)) def list_from(one_or_seq: Union[T, Iterable[T]]) -> List[T]: try: return list(one_or_seq) except Exception: return [one_or_seq] class MemoryType: """Pure type for Memory objects to inherit from."""
from gd.typing import Any, Callable, Type, TypeVar from gd.errors import NotLoggedError, MissingAccess Function = Callable[[Any], Any] __all__ = ( "check_logged", "check_logged_obj", "benchmark", "impl_sync", "source", "sync", "run_once", ) T = TypeVar("T") CF = TypeVar("CF", Type[T], Function) def check_logged(func: Function) -> Function: # decorator that checks if passed client is logged in. @functools.wraps(func) def wrapper(obj: Any, *args, **kwargs) -> Any: # apply actual check check_logged_obj(obj, func.__name__) return func(obj, *args, **kwargs) return wrapper
"ser_enum", "de_float", "ser_float", "de_int", "ser_int", "de_str", "ser_str", "de_url", "ser_url", ) # DO NOT CHANGE ANNOTATIONS = "__annotations__" DATA = "DATA" Model_T = TypeVar("Model") ModelList_T = TypeVar("ModelList") T = TypeVar("T") U = TypeVar("U") class Singleton: instance = None def __repr__(self) -> str: # pragma: no cover return make_repr(self) @classmethod def __new__(cls, *args, **kwargs) -> T: if cls.instance is None:
) __all__ = ( "re_link", "re_name", "re_author", "re_size", "re_attrib", "find_song_info", "extract_info_from_endpoint", "search_song_data", "extract_user_songs", "extract_users", ) T = TypeVar("T") U = TypeVar("U") re_link, re_size, re_name, re_author, re_attrib = ( r"https://audio\.ngfiles\.com/([^\"']+)", r".filesize.:(\d+)", r"<title>([^<>]+)</title>", r".artist.:.([^\"']+).", r"{}[ ]*=[ ]*(?P<quote>[\"'])(.*?)(?P=quote)", ) re_class = re_attrib.format("class") SongInfo = namedtuple("SongInfo", "link size name author") def html_parse(text: str) -> Element:
import sys from gd.typing import Any, Dict, Optional, Type, TypeVar, Union __all__ = ("map_property", "is_null") T = TypeVar("T") U = TypeVar("U") V = TypeVar("V") TEMPLATE = """ def get_{name}(self) -> Optional[TYPE]: return self.{attr}.get({key!r}, {default}) def set_{name}(self, {name}: TYPE) -> None: self.{attr}[{key!r}] = {name} def delete_{name}(self) -> None: try: del self.{attr}[{key!r}] except KeyError: pass {name} = property(get_{name}, set_{name}, delete_{name}) """