Add strategy code to __code__
This commit is contained in:
@@ -67,9 +67,10 @@ class IResolver:
|
||||
return iter([None])
|
||||
|
||||
valid_objects_gen = (
|
||||
obj for name, obj in inspect.getmembers(module, inspect.isclass)
|
||||
if ((object_name is None or object_name == name) and
|
||||
issubclass(obj, cls.object_type) and obj is not cls.object_type)
|
||||
(obj, inspect.getsource(module)) for name, obj in inspect.getmembers(
|
||||
module, inspect.isclass) if ((object_name is None or object_name == name)
|
||||
and issubclass(obj, cls.object_type)
|
||||
and obj is not cls.object_type)
|
||||
)
|
||||
return valid_objects_gen
|
||||
|
||||
@@ -93,7 +94,8 @@ class IResolver:
|
||||
obj = next(cls._get_valid_object(module_path, object_name), None)
|
||||
|
||||
if obj:
|
||||
return (obj, module_path)
|
||||
obj[0].__code__ = obj[1]
|
||||
return (obj[0], module_path)
|
||||
return (None, None)
|
||||
|
||||
@classmethod
|
||||
@@ -133,10 +135,10 @@ class IResolver:
|
||||
user_subdir=cls.user_subdir,
|
||||
extra_dir=extra_dir)
|
||||
|
||||
pairlist = cls._load_object(paths=abs_paths, object_name=object_name,
|
||||
kwargs=kwargs)
|
||||
if pairlist:
|
||||
return pairlist
|
||||
found_object = cls._load_object(paths=abs_paths, object_name=object_name,
|
||||
kwargs=kwargs)
|
||||
if found_object:
|
||||
return found_object
|
||||
raise OperationalException(
|
||||
f"Impossible to load {cls.object_type_str} '{object_name}'. This class does not exist "
|
||||
"or contains Python code errors."
|
||||
@@ -164,8 +166,8 @@ class IResolver:
|
||||
for obj in cls._get_valid_object(module_path, object_name=None,
|
||||
enum_failed=enum_failed):
|
||||
objects.append(
|
||||
{'name': obj.__name__ if obj is not None else '',
|
||||
'class': obj,
|
||||
{'name': obj[0].__name__ if obj is not None else '',
|
||||
'class': obj[0] if obj is not None else None,
|
||||
'location': entry,
|
||||
})
|
||||
return objects
|
||||
|
Reference in New Issue
Block a user