diff options
author | Campbell Barton <campbell@blender.org> | 2022-04-08 02:41:28 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-04-08 04:49:50 +0300 |
commit | 982aea88e0d74020c62c2054a45eeafa56c8ca30 (patch) | |
tree | 6215fe088028a0943ace5ea80e256b7a42132420 /source/blender/python/intern/bpy.c | |
parent | 87a3bf33564b035e4c2400098ea4932d5dfdba5d (diff) |
Cleanup: separate format-units for Python argument parsing
With the increased use of multi-character format units and keyword-only
arguments these are increasingly difficult to make sense of.
Split the string onto multiple lines, one per argument.
While verbose it's easier to understand and add new arguments.
Diffstat (limited to 'source/blender/python/intern/bpy.c')
-rw-r--r-- | source/blender/python/intern/bpy.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 78f9e6eba5e..2ce1da81a2a 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -113,7 +113,15 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec bool local = false; static const char *_keywords[] = {"absolute", "packed", "local", NULL}; - static _PyArg_Parser _parser = {"|$O&O&O&:blend_paths", _keywords, 0}; + static _PyArg_Parser _parser = { + "|$" /* Optional keyword only arguments. */ + "O&" /* `absolute` */ + "O&" /* `packed` */ + "O&" /* `local` */ + ":blend_paths", + _keywords, + 0, + }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, @@ -171,7 +179,6 @@ static PyObject *bpy_flip_name(PyObject *UNUSED(self), PyObject *args, PyObject "s#" /* `name` */ "|$" /* Optional, keyword only arguments. */ "O&" /* `strip_digits` */ - /* Name to show in the case of an error. */ ":flip_name", _keywords, 0, @@ -211,7 +218,14 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj const char *path; static const char *_keywords[] = {"type", "path", NULL}; - static _PyArg_Parser _parser = {"O&|$s:user_resource", _keywords, 0}; + static _PyArg_Parser _parser = { + "O&" /* `type` */ + "|$" /* Optional keyword only arguments. */ + "s" /* `path` */ + ":user_resource", + _keywords, + 0, + }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, PyC_ParseStringEnum, &type, &subdir)) { return NULL; } @@ -247,7 +261,14 @@ static PyObject *bpy_system_resource(PyObject *UNUSED(self), PyObject *args, PyO const char *path; static const char *_keywords[] = {"type", "path", NULL}; - static _PyArg_Parser _parser = {"O&|$s:system_resource", _keywords, 0}; + static _PyArg_Parser _parser = { + "O&" /* `type` */ + "|$" /* Optional keyword only arguments. */ + "s" /* `path` */ + ":system_resource", + _keywords, + 0, + }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, PyC_ParseStringEnum, &type, &subdir)) { return NULL; } @@ -285,7 +306,15 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj const char *path; static const char *_keywords[] = {"type", "major", "minor", NULL}; - static _PyArg_Parser _parser = {"O&|$ii:resource_path", _keywords, 0}; + static _PyArg_Parser _parser = { + "O&" /* `type` */ + "|$" /* Optional keyword only arguments. */ + "i" /* `major` */ + "i" /* `minor` */ + ":resource_path", + _keywords, + 0, + }; if (!_PyArg_ParseTupleAndKeywordsFast( args, kw, &_parser, PyC_ParseStringEnum, &type, &major, &minor)) { return NULL; |