Add enterprise appliance experience Phase 1 foundation
This commit is contained in:
1 parent
b3eec34158
commit
ebaa2e7219
69 files changed
+6832
-18
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import ast
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
MAIN = ROOT / "ansible/roles/cezen-backend/files/main.py"
|
||||
|
||||
|
||||
def load_symbols(*names, globals_dict=None):
|
||||
tree = ast.parse(MAIN.read_text())
|
||||
wanted = []
|
||||
for node in tree.body:
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name in names:
|
||||
wanted.append(node)
|
||||
elif isinstance(node, ast.Assign):
|
||||
assigned = {target.id for target in node.targets if isinstance(target, ast.Name)}
|
||||
if assigned.intersection(names):
|
||||
wanted.append(node)
|
||||
namespace = dict(globals_dict or {})
|
||||
exec(compile(ast.Module(body=wanted, type_ignores=[]), str(MAIN), "exec"), namespace)
|
||||
return namespace
|
||||
Reference in new issue
Block a user