reactiveData/plt/getPythonSupportFunctionsDefinition.inc.php
Frederico Falcao 14f96e78f9 IMPROVEMENT: bring Python trigger support to parity with PHP.
Add SQL bridge, support functions, cron jobs, error handling, and PyPI version pinning so Python triggers match PHP capabilities.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 00:13:18 +03:00

18 lines
701 B
PHP

<?php
/**
* Builds Python support function definitions from SYS_PRD_BND.SupportFunctions.
*/
function getPythonSupportFunctionsDefinition() {
$functions = "";
foreach (sql("SELECT Name, InputArgs_json, PythonCode FROM SYS_PRD_BND.SupportFunctions WHERE PythonCode IS NOT NULL") as $f) {
$inputArgs = json_decode($f['InputArgs_json'], true);
$argNames = is_array($inputArgs) ? array_keys($inputArgs) : [];
$argsString = implode(', ', $argNames);
$indentedBody = implode("\n", array_map(fn($line) => ' ' . $line, explode("\n", $f['PythonCode'])));
$functions .= "def {$f['Name']}($argsString):\n{$indentedBody}\n\n";
}
return $functions;
}