File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
src/telegrambots/custom/extensions Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1
1
[metadata]
2
2
name = telegrambots-custom
3
- version = 0.0.7rc2
3
+ version = 0.0.7rc3
4
4
author = immmdreza
5
5
author_email = ir310022@gmail.com
6
6
description = A custom extension packages for telegrambots.
Original file line number Diff line number Diff line change 1
1
import importlib
2
2
import inspect
3
+ import logging
3
4
import os
4
5
from abc import ABC
5
6
from pathlib import Path
17
18
if TYPE_CHECKING :
18
19
from .. import Dispatcher
19
20
21
+ logging .basicConfig (
22
+ format = "%(asctime)s %(message)s" ,
23
+ datefmt = "%m/%d/%Y %I:%M:%S %p" ,
24
+ level = logging .INFO ,
25
+ )
26
+ dispatcher_logger = logging .getLogger ("telegrambots.dispatcher" )
27
+
20
28
21
29
class DispatcherExtensions (ABC ):
22
30
def __init__ (self , dp : "Dispatcher" ) -> None :
@@ -254,16 +262,14 @@ def locate(self, path: Path):
254
262
try :
255
263
module = importlib .import_module (module_name )
256
264
257
- for name , obj in inspect .getmembers (module , inspect .isclass ):
265
+ for _ , obj in inspect .getmembers (module , inspect .isclass ):
258
266
if issubclass (obj , AbstractHandler ):
259
267
if not inspect .isabstract (obj ):
260
268
instance : AbstractHandler [Any , Any ] = obj () # type: ignore
261
269
instance .set_dp (self ._dp )
262
270
self ._dp .add_handler (instance )
263
-
264
- yield name
265
-
266
- except ImportError :
271
+ except ImportError as e :
272
+ dispatcher_logger .error (f"Failed to import module { module_name } : { e } " )
267
273
continue
268
274
269
275
You can’t perform that action at this time.
0 commit comments