Passed
Push — main ( d0b3ac...149404 )
by
unknown
01:45
created

pincer.middleware   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 8
dl 0
loc 61
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# MIT License
3
#
4
# Copyright (c) 2021 Pincer
5
#
6
# Permission is hereby granted, free of charge, to any person obtaining
7
# a copy of this software and associated documentation files
8
# (the "Software"), to deal in the Software without restriction,
9
# including without limitation the rights to use, copy, modify, merge,
10
# publish, distribute, sublicense, and/or sell copies of the Software,
11
# and to permit persons to whom the Software is furnished to do so,
12
# subject to the following conditions:
13
#
14
# The above copyright notice and this permission notice shall be
15
# included in all copies or substantial portions of the Software.
16
#
17
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
from typing import Dict
26
27
from pincer.utils import Coro
28
from .interaction_create import interaction_create_middleware
29
from .ready import on_ready_middleware
30
31
# TODO: Make imports dynamic.
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
32
# from glob import glob
33
# from importlib import import_module
34
# from os import path
35
# from pathlib import Path
36
# from pincer.exceptions import NoExportMethod
37
38
# def get_middleware() -> Dict[str, Coro]:
39
#     middleware_list: Dict[str, Coro] = {}
40
#
41
#     for middleware_path in glob(path.join(
42
#             Path(__file__).parent.resolve(),
43
#             "[!__init__]*.py")
44
#     ):
45
#         event = middleware_path[:-3]
46
#
47
#         try:
48
#             middleware_list[event] = getattr(import_module(f"event"), "export")
49
#         except AttributeError:
50
#             raise NoExportMethod(
51
#                 f"Middleware module `{middleware_path}` expected an "
52
#                 "`export` method but none was found!"
53
#             )
54
#
55
#     return middleware_list
56
# middleware: Dict[str, Coro] = get_middleware()
57
58
middleware: Dict[str, Coro] = {
59
    "ready": on_ready_middleware,
60
    "interaction_create": interaction_create_middleware
61
}
62