[Bf-blender-cvs] [9f2665b5262] master: PyAPI: utility function to print reports
Campbell Barton
noreply at git.blender.org
Wed Mar 27 04:06:44 CET 2019
Commit: 9f2665b52624eb1dbf75f479c5d9529ca067f29a
Author: Campbell Barton
Date: Wed Mar 27 14:01:25 2019 +1100
Branches: master
https://developer.blender.org/rB9f2665b52624eb1dbf75f479c5d9529ca067f29a
PyAPI: utility function to print reports
===================================================================
M source/blender/python/intern/bpy_capi_utils.c
M source/blender/python/intern/bpy_capi_utils.h
M source/blender/python/intern/bpy_operator.c
===================================================================
diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c
index 4c0d220d3d9..3a5b3077ee6 100644
--- a/source/blender/python/intern/bpy_capi_utils.c
+++ b/source/blender/python/intern/bpy_capi_utils.c
@@ -75,6 +75,19 @@ short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool
return (report_str == NULL) ? 0 : -1;
}
+/**
+ * A version of #BKE_report_write_file_fp that uses Python's stdout.
+ */
+void BPy_reports_write_stdout(const ReportList *reports, const char *header)
+{
+ if (header) {
+ PySys_WriteStdout("%s\n", header);
+ }
+
+ for (const Report *report = reports->list.first; report; report = report->next) {
+ PySys_WriteStdout("%s: %s\n", report->typestr, report->message);
+ }
+}
bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const bool use_location)
{
diff --git a/source/blender/python/intern/bpy_capi_utils.h b/source/blender/python/intern/bpy_capi_utils.h
index 533ff0fb7c2..f8d42b463ac 100644
--- a/source/blender/python/intern/bpy_capi_utils.h
+++ b/source/blender/python/intern/bpy_capi_utils.h
@@ -34,6 +34,7 @@ char *BPy_enum_as_string(const struct EnumPropertyItem *item);
/* error reporting */
short BPy_reports_to_error(struct ReportList *reports, PyObject *exception, const bool clear);
+void BPy_reports_write_stdout(const struct ReportList *reports, const char *header);
bool BPy_errors_to_report_ex(struct ReportList *reports, const bool use_full, const bool use_location);
bool BPy_errors_to_report(struct ReportList *reports);
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index ecae71d07e3..98b2f871c54 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -262,10 +262,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
/* operator output is nice to have in the terminal/console too */
if (!BLI_listbase_is_empty(&reports->list)) {
- Report *report;
- for (report = reports->list.first; report; report = report->next) {
- PySys_WriteStdout("%s: %s\n", report->typestr, report->message);
- }
+ BPy_reports_write_stdout(reports, NULL);
}
BKE_reports_clear(reports);
More information about the Bf-blender-cvs
mailing list