lib.Types.LoadTypes: Beautify logging code
Shorten redundant occurences of .format(mod_name, member_name).
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
a9e0d486df
commit
a3279a3b00
1 changed files with 7 additions and 19 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import abc
|
||||
import os
|
||||
import re
|
||||
|
|
@ -86,35 +87,22 @@ class LoadTypes(Types[T]): # export
|
|||
for member_name, c in inspect.getmembers(
|
||||
sys.modules[mod_name], inspect.isclass
|
||||
):
|
||||
name = f'{mod_name}.{member_name}'
|
||||
if rx is not None and not re.match(rx, member_name):
|
||||
self._debug(
|
||||
'o "{}.{}" has wrong name'.format(mod_name, member_name)
|
||||
)
|
||||
self._debug(f'o "{name}" has wrong name')
|
||||
continue
|
||||
if inspect.isabstract(c):
|
||||
self._debug(
|
||||
'o "{}.{}" is abstract'.format(mod_name, member_name)
|
||||
)
|
||||
self._debug(f'o "{name}" is abstract: {c.__abstractmethods__}')
|
||||
continue
|
||||
if self.__type_filter:
|
||||
for tp in self.__type_filter:
|
||||
if issubclass(c, tp):
|
||||
break
|
||||
self._debug(
|
||||
'o "{}.{}" is not of type {}'.format(
|
||||
mod_name, member_name, tp
|
||||
)
|
||||
)
|
||||
self._debug(f'o "{name}" is not of type {tp}')
|
||||
else:
|
||||
self._debug(
|
||||
'o "{}.{}" doesn\'t match type filter'.format(
|
||||
mod_name, member_name
|
||||
)
|
||||
)
|
||||
self._debug(f'o "{name}" doesn\'t match type filter')
|
||||
continue
|
||||
self._debug(
|
||||
'o "{}.{}" is fine, adding'.format(mod_name, member_name)
|
||||
)
|
||||
self._debug(f'o "{name}" is fine, adding')
|
||||
ret.append(c)
|
||||
self.__classes = ret
|
||||
return self.__classes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue