Cleanup: strip trailing space in Python module

This commit is contained in:
2018-06-04 08:54:17 +02:00
parent 854db8951b
commit 7719c11006
23 changed files with 112 additions and 112 deletions

View File

@@ -169,7 +169,7 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
return NULL;
}
/* same logic as BKE_appdir_folder_id_create(), but best leave it up to the script author to create */
path = BKE_appdir_folder_id(folder_id, subdir);

View File

@@ -243,10 +243,10 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *clos
PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
return -1;
}
if (param) G.debug |= flag;
else G.debug &= ~flag;
return 0;
}
@@ -297,7 +297,7 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void
PyErr_SetString(PyExc_TypeError, "bpy.app.debug_value can only be set to a whole number");
return -1;
}
G.debug_value = param;
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -396,7 +396,7 @@ static void py_struct_seq_getset_init(void)
PyObject *BPY_app_struct(void)
{
PyObject *ret;
PyStructSequence_InitType(&BlenderAppType, &app_info_desc);
ret = make_app_info();

View File

@@ -88,21 +88,21 @@ bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const boo
if (!PyErr_Occurred())
return 1;
/* less hassle if we allow NULL */
if (reports == NULL) {
PyErr_Print();
PyErr_Clear();
return 1;
}
if (use_full) {
pystring = PyC_ExceptionBuffer();
}
else {
pystring = PyC_ExceptionBuffer_Simple();
}
if (pystring == NULL) {
BKE_report(reports, RPT_ERROR, "Unknown py-exception, could not convert");
return 0;

View File

@@ -285,7 +285,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, c
for (dvar = driver->variables.first, i = 0; dvar; dvar = dvar->next) {
PyTuple_SET_ITEM(expr_vars, i++, PyUnicode_FromString(dvar->name));
}
driver->flag &= ~DRIVER_FLAG_RENAMEVAR;
}
else {
@@ -342,7 +342,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, ChannelDriver *driver, c
fprintf(stderr, "\nBPY_driver_eval() - Error while evaluating PyDriver:\n");
targets_ok = 0;
}
fprintf(stderr, "\tBPY_driver_eval() - couldn't add variable '%s' to namespace\n", dvar->name);
// BPy_errors_to_report(NULL); // TODO - reports
PyErr_Print();

View File

@@ -289,7 +289,7 @@ void BPY_python_start(int argc, const char **argv)
PySys_SetObject("argv", py_argv);
Py_DECREF(py_argv);
}
/* Initialize thread support (also acquires lock) */
PyEval_InitThreads();
#else
@@ -328,7 +328,7 @@ void BPY_python_start(int argc, const char **argv)
BPy_init_modules();
bpy_import_init(PyEval_GetBuiltins());
pyrna_alloc_types();
#ifndef WITH_PYTHON_MODULE
@@ -347,7 +347,7 @@ void BPY_python_end(void)
/* finalizing, no need to grab the state, except when we are a module */
gilstate = PyGILState_Ensure();
/* free other python data. */
pyrna_free_types();
@@ -693,7 +693,7 @@ bool BPY_execute_string_ex(bContext *C, const char *expr, bool use_eval)
PyC_MainModule_Restore(main_mod);
bpy_context_clear(C, &gilstate);
return ok;
}
@@ -877,7 +877,7 @@ static void bpy_module_delay_init(PyObject *bpy_proxy)
argv[0] = filename_abs;
argv[1] = NULL;
// printf("module found %s\n", argv[0]);
main_python_enter(argc, argv);
@@ -906,14 +906,14 @@ PyMODINIT_FUNC
PyInit_bpy(void)
{
PyObject *bpy_proxy = PyModule_Create(&bpy_proxy_def);
/* Problem:
* 1) this init function is expected to have a private member defined - 'md_def'
* but this is only set for C defined modules (not py packages)
* so we cant return 'bpy_package_py' as is.
*
* 2) there is a 'bpy' C module for python to load which is basically all of blender,
* and there is scripts/bpy/__init__.py,
* and there is scripts/bpy/__init__.py,
* we may end up having to rename this module so there is no naming conflict here eg:
* 'from blender import bpy'
*
@@ -923,13 +923,13 @@ PyInit_bpy(void)
/* assign an object which is freed after __file__ is assigned */
dealloc_obj *dob;
/* assign dummy type */
dealloc_obj_Type.tp_name = "dealloc_obj";
dealloc_obj_Type.tp_basicsize = sizeof(dealloc_obj);
dealloc_obj_Type.tp_dealloc = dealloc_obj_dealloc;
dealloc_obj_Type.tp_flags = Py_TPFLAGS_DEFAULT;
if (PyType_Ready(&dealloc_obj_Type) < 0)
return NULL;

View File

@@ -79,7 +79,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
/* XXX Todo, work out a better solution for passing on context,
* could make a tuple from self and pack the name and Context into it... */
bContext *C = (bContext *)BPy_GetContext();
if (C == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
return NULL;
@@ -87,7 +87,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
if (!PyArg_ParseTuple(args, "s|Os:_bpy.ops.poll", &opname, &context_dict, &context_str))
return NULL;
ot = WM_operatortype_find(opname, true);
if (ot == NULL) {
@@ -108,7 +108,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
}
if (context_dict == NULL || context_dict == Py_None) {
context_dict = NULL;
}
@@ -123,10 +123,10 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
context_dict_back = CTX_py_dict_get(C);
CTX_py_dict_set(C, (void *)context_dict);
Py_XINCREF(context_dict); /* so we done loose it */
/* main purpose of thsi function */
ret = WM_operator_poll_context((bContext *)C, ot, context) ? Py_True : Py_False;
/* restore with original context dict, probably NULL but need this for nested operator calls */
Py_XDECREF(context_dict);
CTX_py_dict_set(C, (void *)context_dict_back);
@@ -154,12 +154,12 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
/* XXX Todo, work out a better solution for passing on context,
* could make a tuple from self and pack the name and Context into it... */
bContext *C = (bContext *)BPy_GetContext();
if (C == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
return NULL;
}
if (!PyArg_ParseTuple(args, "sO|O!si:_bpy.ops.call",
&opname, &context_dict, &PyDict_Type, &kw, &context_str, &is_undo))
{
@@ -174,7 +174,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
"could not be found", opname);
return NULL;
}
if (!pyrna_write_check()) {
PyErr_Format(PyExc_RuntimeError,
"Calling operator \"bpy.ops.%s\" error, "
@@ -259,7 +259,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
PySys_WriteStdout("%s: %s\n", report->typestr, report->message);
}
}
BKE_reports_clear(reports);
if ((reports->flag & RPT_FREE) == 0) {
MEM_freeN(reports);
@@ -330,7 +330,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant get the string representation of this object.");
return NULL;
}
if (!PyArg_ParseTuple(
args, "s|O!O&O&:_bpy.ops.as_string",
&opname, &PyDict_Type, &kw,
@@ -400,7 +400,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
PointerRNA ptr;
const char *opname = _PyUnicode_AsString(value);
BPy_StructRNA *pyrna = NULL;
if (opname == NULL) {
PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_rna() expects a string argument");
return NULL;
@@ -410,7 +410,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
PyErr_Format(PyExc_KeyError, "_bpy.ops.get_rna(\"%s\") not found", opname);
return NULL;
}
/* type */
//RNA_pointer_create(NULL, &RNA_Struct, ot->srna, &ptr);
@@ -418,7 +418,7 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
WM_operator_properties_create_ptr(&ptr, ot);
WM_operator_properties_sanitize(&ptr, 0);
pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
#ifdef PYRNA_FREE_SUPPORT
pyrna->freeptr = true;

View File

@@ -366,7 +366,7 @@ static void bpy_prop_boolean_set_cb(struct PointerRNA *ptr, struct PropertyRNA *
Py_DECREF(ret);
}
if (use_gil)
PyGILState_Release(gilstate);
@@ -1329,7 +1329,7 @@ static int icon_id_from_name(const char *name)
}
}
}
return 0;
}
@@ -1631,7 +1631,7 @@ static void bpy_prop_callback_assign_boolean(struct PropertyRNA *prop, PyObject
{
BooleanPropertyGetFunc rna_get_cb = NULL;
BooleanPropertySetFunc rna_set_cb = NULL;
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1653,7 +1653,7 @@ static void bpy_prop_callback_assign_boolean_array(struct PropertyRNA *prop, PyO
{
BooleanArrayPropertyGetFunc rna_get_cb = NULL;
BooleanArrayPropertySetFunc rna_set_cb = NULL;
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1675,7 +1675,7 @@ static void bpy_prop_callback_assign_int(struct PropertyRNA *prop, PyObject *get
{
IntPropertyGetFunc rna_get_cb = NULL;
IntPropertySetFunc rna_set_cb = NULL;
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1697,7 +1697,7 @@ static void bpy_prop_callback_assign_int_array(struct PropertyRNA *prop, PyObjec
{
IntArrayPropertyGetFunc rna_get_cb = NULL;
IntArrayPropertySetFunc rna_set_cb = NULL;
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1719,7 +1719,7 @@ static void bpy_prop_callback_assign_float(struct PropertyRNA *prop, PyObject *g
{
FloatPropertyGetFunc rna_get_cb = NULL;
FloatPropertySetFunc rna_set_cb = NULL;
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1741,7 +1741,7 @@ static void bpy_prop_callback_assign_float_array(struct PropertyRNA *prop, PyObj
{
FloatArrayPropertyGetFunc rna_get_cb = NULL;
FloatArrayPropertySetFunc rna_set_cb = NULL;
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1764,7 +1764,7 @@ static void bpy_prop_callback_assign_string(struct PropertyRNA *prop, PyObject *
StringPropertyGetFunc rna_get_cb = NULL;
StringPropertyLengthFunc rna_length_cb = NULL;
StringPropertySetFunc rna_set_cb = NULL;
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1788,7 +1788,7 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, PyObject *ge
EnumPropertyGetFunc rna_get_cb = NULL;
EnumPropertyItemFunc rna_itemf_cb = NULL;
EnumPropertySetFunc rna_set_cb = NULL;
if (get_cb && get_cb != Py_None) {
PyObject **py_data = bpy_prop_py_data_get(prop);
@@ -1815,7 +1815,7 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, PyObject *ge
RNA_def_property_enum_funcs_runtime(prop, rna_get_cb, rna_set_cb, rna_itemf_cb);
}
/* this define runs at the start of each function and deals with
/* this define runs at the start of each function and deals with
* returning a deferred property (to be registered later) */
#define BPY_PROPDEF_HEAD(_func) \
if (PyTuple_GET_SIZE(args) == 1) { \
@@ -2166,7 +2166,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
bpy_prop_callback_assign_boolean_array(prop, get_cb, set_cb);
RNA_def_property_duplicate_pointers(srna, prop);
}
Py_RETURN_NONE;
}
@@ -2801,7 +2801,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
StructRNA *srna;
BPY_PROPDEF_HEAD(EnumProperty);
if (srna) {
const char *id = NULL, *name = NULL, *description = "";
PyObject *def = NULL;
@@ -3195,7 +3195,7 @@ PyObject *BPY_rna_props(void)
{
PyObject *submodule;
PyObject *submodule_dict;
submodule = PyModule_Create(&props_module);
PyDict_SetItemString(PyImport_GetModuleDict(), props_module.m_name, submodule);
@@ -3203,7 +3203,7 @@ PyObject *BPY_rna_props(void)
* module with a new ref like PyDict_New, since they are passed to
* PyModule_AddObject which steals a ref */
Py_INCREF(submodule);
/* api needs the PyObjects internally */
submodule_dict = PyModule_GetDict(submodule);
@@ -3220,6 +3220,6 @@ PyObject *BPY_rna_props(void)
ASSIGN_STATIC(PointerProperty);
ASSIGN_STATIC(CollectionProperty);
ASSIGN_STATIC(RemoveProperty);
return submodule;
}

View File

@@ -233,13 +233,13 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
*/
ReportList reports;
short result = 0;
PointerRNA ptr = self->ptr;
PropertyRNA *prop = NULL;
const char *prop_name;
BKE_reports_init(&reports, RPT_STORE);
/* Retrieve the property identifier from the full path, since we can't get it any other way */
prop_name = strrchr(path_full, '.');
if ((prop_name >= path_full) &&
@@ -247,21 +247,21 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
{
prop = RNA_struct_find_property(&ptr, prop_name + 1);
}
if (prop) {
NlaStrip *strip = (NlaStrip *)ptr.data;
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index);
result = insert_keyframe_direct(&reports, ptr, prop, fcu, cfra, keytype, options);
}
else {
BKE_reportf(&reports, RPT_ERROR, "Could not resolve path (%s)", path_full);
}
MEM_freeN((void *)path_full);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
return NULL;
return PyBool_FromLong(result);
}
else {
@@ -320,13 +320,13 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
*/
ReportList reports;
short result = 0;
PointerRNA ptr = self->ptr;
PropertyRNA *prop = NULL;
const char *prop_name;
BKE_reports_init(&reports, RPT_STORE);
/* Retrieve the property identifier from the full path, since we can't get it any other way */
prop_name = strrchr(path_full, '.');
if ((prop_name >= path_full) &&
@@ -334,14 +334,14 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
{
prop = RNA_struct_find_property(&ptr, prop_name + 1);
}
if (prop) {
ID *id = ptr.id.data;
NlaStrip *strip = (NlaStrip *)ptr.data;
FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index);
BLI_assert(fcu != NULL); /* NOTE: This should be true, or else we wouldn't be able to get here */
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(&reports, RPT_WARNING,
"Not deleting keyframe for locked F-Curve for NLA Strip influence on %s - %s '%s'",
@@ -354,7 +354,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
*/
bool found = false;
int i;
/* try to find index of beztriple to get rid of */
i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found);
if (found) {
@@ -368,10 +368,10 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
BKE_reportf(&reports, RPT_ERROR, "Could not resolve path (%s)", path_full);
}
MEM_freeN((void *)path_full);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
return NULL;
return PyBool_FromLong(result);
}
else {
@@ -423,7 +423,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
BKE_reports_init(&reports, RPT_STORE);
result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index,
result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index,
CREATEDRIVER_WITH_FMODIFIER, DRIVER_TYPE_PYTHON);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
@@ -449,7 +449,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
ret = pyrna_struct_CreatePyObject(&tptr);
}
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
}
else {
@@ -502,7 +502,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
return NULL;
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
return PyBool_FromLong(result);

View File

@@ -277,10 +277,10 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
* dimsize[1] = 4
* dimsize[2] = 5
* lvalue_dim = 0, totdim = 3
*
*
* arr[2][3] = x
* lvalue_dim = 1
*
*
* arr[2][3][4] = x
* lvalue_dim = 2 */
for (i = lvalue_dim; i < totdim; i++)
@@ -805,7 +805,7 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr,
*
* x = arr[2]
* index = 0 + 2 * 4 * 5
*
*
* x = arr[2][3]
* index = offset + 3 * 5 */

View File

@@ -93,7 +93,7 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
if (!PyArg_ParseTuple(args, "OO!|s:bpy_struct.callback_add", &cb_func, &PyTuple_Type, &cb_args, &cb_event_str))
return NULL;
if (!PyCallable_Check(cb_func)) {
PyErr_SetString(PyExc_TypeError, "callback_add(): first argument isn't callable");
return NULL;