Add argument --python-expr to pass Python directly
This works like Python's -c argument, handy to be able to avoid writing small scripts to disk.
This commit is contained in:
@@ -607,7 +607,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const bool ver
|
||||
return error_ret;
|
||||
}
|
||||
|
||||
int BPY_string_exec(bContext *C, const char *expr)
|
||||
int BPY_string_exec_ex(bContext *C, const char *expr, bool use_eval)
|
||||
{
|
||||
PyGILState_STATE gilstate;
|
||||
PyObject *main_mod = NULL;
|
||||
@@ -630,7 +630,7 @@ int BPY_string_exec(bContext *C, const char *expr)
|
||||
bmain_back = bpy_import_main_get();
|
||||
bpy_import_main_set(CTX_data_main(C));
|
||||
|
||||
retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict);
|
||||
retval = PyRun_String(expr, use_eval ? Py_eval_input : Py_file_input, py_dict, py_dict);
|
||||
|
||||
bpy_import_main_set(bmain_back);
|
||||
|
||||
@@ -650,6 +650,10 @@ int BPY_string_exec(bContext *C, const char *expr)
|
||||
return error_ret;
|
||||
}
|
||||
|
||||
int BPY_string_exec(bContext *C, const char *expr)
|
||||
{
|
||||
return BPY_string_exec_ex(C, expr, true);
|
||||
}
|
||||
|
||||
void BPY_modules_load_user(bContext *C)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user