Refactored sheerka execution flow + Enhanced log management
This commit is contained in:
+18
-2
@@ -113,16 +113,21 @@ def get_classes_from_package(package_name):
|
||||
yield c
|
||||
|
||||
|
||||
def get_sub_classes(package_name, base_class):
|
||||
def init_package_import(package_name):
|
||||
pkg = __import__(package_name)
|
||||
prefix = pkg.__name__ + "."
|
||||
for (module_loader, name, ispkg) in pkgutil.iter_modules(pkg.__path__, prefix):
|
||||
importlib.import_module(name)
|
||||
|
||||
|
||||
def get_sub_classes(package_name, base_class):
|
||||
base_class = get_class(base_class) if isinstance(base_class, str) else base_class
|
||||
return set(base_class.__subclasses__()).union(
|
||||
all_class = set(base_class.__subclasses__()).union(
|
||||
[s for c in base_class.__subclasses__() for s in get_sub_classes(package_name, c)])
|
||||
|
||||
# limit to the classes of the package
|
||||
return [c for c in all_class if c.__module__.startswith(package_name)]
|
||||
|
||||
|
||||
def remove_from_list(lst, to_remove_predicate):
|
||||
"""
|
||||
@@ -143,6 +148,17 @@ def remove_from_list(lst, to_remove_predicate):
|
||||
return lst
|
||||
|
||||
|
||||
def remove_list_from_list(lst, to_remove):
|
||||
# https://stackoverflow.com/questions/2514961/remove-all-values-within-one-list-from-another-list/30353802
|
||||
# explains that list comprehension is not the best approach
|
||||
for item in to_remove:
|
||||
try:
|
||||
lst.remove(item)
|
||||
except ValueError:
|
||||
pass
|
||||
return lst
|
||||
|
||||
|
||||
def product(a, b):
|
||||
"""
|
||||
Kind of cartesian product between lists a and b
|
||||
|
||||
Reference in New Issue
Block a user