core.common: move stats-related stuff to my.core.stats and add more thorough tests/docs
deprecate core.common.stat and core.common.Stats with backwards compatibility
This commit is contained in:
parent
18529257e7
commit
c45c51af22
14 changed files with 343 additions and 246 deletions
|
@ -1,6 +1,5 @@
|
|||
from pathlib import Path
|
||||
from itertools import chain
|
||||
from importlib import import_module
|
||||
import os
|
||||
import pkgutil
|
||||
import sys
|
||||
|
@ -15,17 +14,6 @@ def modules() -> Iterable[HPIModule]:
|
|||
yield m
|
||||
|
||||
|
||||
from .common import StatsFun
|
||||
def get_stats(module: str) -> Optional[StatsFun]:
|
||||
# todo detect via ast?
|
||||
try:
|
||||
mod = import_module(module)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
return getattr(mod, 'stats', None)
|
||||
|
||||
|
||||
__NOT_HPI_MODULE__ = 'Import this to mark a python file as a helper, not an actual HPI module'
|
||||
from .discovery_pure import NOT_HPI_MODULE_VAR
|
||||
assert NOT_HPI_MODULE_VAR in globals() # check name consistency
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue