Package Manager API
The PackageManager class dynamically loads external Python packages into the
executor and callback executor at runtime.
PackageManager
- class PackageManager
- check_package(package)
Checks if a package is installed and importable.
- Parameters:
package (str) – Package name to check.
- Returns:
The imported module if found,
Noneotherwise.
- add_package_to_executor(package)
Loads all functions, built-ins, and classes from a package into the main executor’s
event_dict.- Parameters:
package (str) – Package name to load.
Functions are added with the naming convention
package_function. For example,time.sleepbecomestime_sleep.
- add_package_to_callback_executor(package)
Loads all functions, built-ins, and classes from a package into the callback executor’s
event_dict.- Parameters:
package (str) – Package name to load.
- get_member(package, predicate, target)
Retrieves members from a package matching the given predicate and adds them to the target executor.
- Parameters:
package (str) – Package name.
predicate – Inspection predicate (e.g.,
isfunction,isclass).target – Target executor whose
event_dictwill be updated.
- add_package_to_target(package, target)
Loads functions, built-ins, and classes from a package into the specified target executor.
- Parameters:
package (str) – Package name.
target – Target executor.
Example:
from je_auto_control import package_manager
# Add 'os' module to the executor
package_manager.add_package_to_executor("os")
# Now you can use os functions in JSON actions:
# ["os_getcwd", {}]
# ["os_listdir", {"path": "."}]