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
|
from __future__ import annotations
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
@ -86,35 +87,22 @@ class LoadTypes(Types[T]): # export
|
||||||
for member_name, c in inspect.getmembers(
|
for member_name, c in inspect.getmembers(
|
||||||
sys.modules[mod_name], inspect.isclass
|
sys.modules[mod_name], inspect.isclass
|
||||||
):
|
):
|
||||||
|
name = f'{mod_name}.{member_name}'
|
||||||
if rx is not None and not re.match(rx, member_name):
|
if rx is not None and not re.match(rx, member_name):
|
||||||
self._debug(
|
self._debug(f'o "{name}" has wrong name')
|
||||||
'o "{}.{}" has wrong name'.format(mod_name, member_name)
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
if inspect.isabstract(c):
|
if inspect.isabstract(c):
|
||||||
self._debug(
|
self._debug(f'o "{name}" is abstract: {c.__abstractmethods__}')
|
||||||
'o "{}.{}" is abstract'.format(mod_name, member_name)
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
if self.__type_filter:
|
if self.__type_filter:
|
||||||
for tp in self.__type_filter:
|
for tp in self.__type_filter:
|
||||||
if issubclass(c, tp):
|
if issubclass(c, tp):
|
||||||
break
|
break
|
||||||
self._debug(
|
self._debug(f'o "{name}" is not of type {tp}')
|
||||||
'o "{}.{}" is not of type {}'.format(
|
|
||||||
mod_name, member_name, tp
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self._debug(
|
self._debug(f'o "{name}" doesn\'t match type filter')
|
||||||
'o "{}.{}" doesn\'t match type filter'.format(
|
|
||||||
mod_name, member_name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
self._debug(
|
self._debug(f'o "{name}" is fine, adding')
|
||||||
'o "{}.{}" is fine, adding'.format(mod_name, member_name)
|
|
||||||
)
|
|
||||||
ret.append(c)
|
ret.append(c)
|
||||||
self.__classes = ret
|
self.__classes = ret
|
||||||
return self.__classes
|
return self.__classes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue