This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from inspect import signature | |
from di.container import Container | |
from di.dependant import Dependant | |
from di.executors import AsyncExecutor | |
from fastapi import APIRouter | |
def copy_signature(source_fct): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SemiEnumMeta(type): | |
def __new__(mcs, name, bases, class_dict): | |
class_ = super().__new__(mcs, name, bases, class_dict) | |
class_.__value_mapping = {} | |
for name, value in class_dict.items(): | |
if name.startswith("__"): | |
continue | |
instance = class_(value) | |
setattr(class_, name, instance) | |
class_.__value_mapping[value] = instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import Enum | |
from logging import getLogger, basicConfig, INFO | |
from typing import Any, Optional | |
logger = getLogger(__name__) | |
class ErrorType(Enum): | |
def __add__(self, other): | |
return self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import logging | |
import operator | |
from typing import Any, Tuple, List | |
from aiogram import Bot, Dispatcher | |
from aiogram.contrib.fsm_storage.memory import MemoryStorage | |
from aiogram.dispatcher.filters.state import StatesGroup, State | |
from aiogram.types import CallbackQuery | |
from magic_filter import F |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import logging | |
from operator import itemgetter | |
from aiogram import Bot, Dispatcher | |
from aiogram.contrib.fsm_storage.memory import MemoryStorage | |
from aiogram.dispatcher.filters.state import StatesGroup, State | |
from aiogram_dialog import Dialog, Window, DialogRegistry | |
from aiogram_dialog.widgets.kbd import ScrollingGroup, Multiselect, Calendar, Radio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Dict | |
from aiogram.types import InlineKeyboardButton, CallbackQuery | |
from aiogram_dialog.dialog import Dialog | |
from aiogram_dialog.manager.protocols import DialogManager | |
from aiogram_dialog.widgets.kbd.base import Keyboard | |
from aiogram_dialog.widgets.managed import ManagedWidgetAdapter | |
from aiogram_dialog.widgets.text import Const, Format | |
from aiogram_dialog.widgets.when import WhenCondition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### library mode | |
import inspect | |
def res_var_name(fname): | |
return f"_{fname}_result_" | |
def result(value, offset=1): | |
stack = inspect.stack() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import logging | |
from typing import Any | |
from aiogram import Bot, Dispatcher | |
from aiogram.contrib.fsm_storage.memory import MemoryStorage | |
from aiogram.dispatcher.filters.state import StatesGroup, State | |
from aiogram.types import CallbackQuery | |
from aiogram_dialog import Dialog, DialogManager, Window, DialogRegistry, Data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import logging | |
import operator | |
from typing import Any | |
from aiogram import Bot, Dispatcher | |
from aiogram.contrib.fsm_storage.memory import MemoryStorage | |
from aiogram.dispatcher.filters.state import StatesGroup, State | |
from aiogram.types import CallbackQuery |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def merge(rule): | |
def merge(a, b): | |
res = {} | |
for key in a.keys() | b.keys(): | |
res[key] = rule[key](a.get(key), b.get(key)) | |
return res | |
return merge | |