itom
Loading...
Searching...
No Matches
pythonCommon.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23#ifndef PYTHONCOMMON_H
24#define PYTHONCOMMON_H
25
26#ifndef NPY_1_7_API_VERSION
27 #define NPY_1_7_API_VERSION 0x00000007
28#endif
29#ifndef NPY_1_8_API_VERSION
30 #define NPY_1_8_API_VERSION 0x00000008
31#endif
32
33#ifndef Q_MOC_RUN
34 #include "python/pythonWrapper.h"
35#endif
36
37#include "../../common/sharedStructures.h"
38
39#include <qvector.h>
40#include <qvariant.h>
41
42namespace ito
43{
44
45 ito::RetVal checkAndSetParamVal(PyObject *tempObj, ito::Param *param, int *set);
46 ito::RetVal checkAndSetParamVal(PyObject *pyObj, const ito::Param *defaultParam, ito::ParamBase &outParam, int *set);
48 PyObject* printOutParams(const QVector<ito::Param> *params, bool asErr, bool addInfos, const int num, bool printToStdStream = true);
49 PyObject *parseParamMetaAsDict(const ito::ParamMeta *meta, const ito::Param* param = nullptr);
50 void errOutInitParams(const QVector<ito::Param> *params, const int num, const char *reason);
51 ito::RetVal parseInitParams(const QVector<ito::Param> *defaultParamListMand, const QVector<ito::Param> *defaultParamListOpt, PyObject *args, PyObject *kwds, QVector<ito::ParamBase> &paramListMandOut, QVector<ito::ParamBase> &paramListOptOut);
52 ito::RetVal copyParamVector(const QVector<ito::ParamBase> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
53 ito::RetVal copyParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::Param> &paramVecOut);
54 ito::RetVal copyParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
55 ito::RetVal createEmptyParamBaseFromParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
56
58 ito::RetVal findAndDeleteReservedInitKeyWords(PyObject *kwds, bool * enableAutoLoadParams);
59
60 PyObject* buildFilterOutputValues(QVector<QVariant> *outVals, ito::RetVal &retValue);
61
63 {
64 public:
65
67 /*
68 The values must only be changed in accordance to the
69 argument 'mode' of the method 'check' of the python
70 module itomSyntaxCheck.py (itom-packages subfolder).
71
72 @seealso WidgetPropEditorCodeCheckers
73 */
81
89
90 enum tErrMsg
91 {
92 noMsg = 0,
93 loadPlugin = 1,
94 execFunc = 2,
95 invokeFunc = 3,
96 getProperty = 4,
97 runFunc = 5
98 };
99
100 static bool transformRetValToPyException(ito::RetVal &retVal, PyObject *exceptionIfError = PyExc_RuntimeError, PyObject *exceptionIfWarning = PyExc_RuntimeWarning);
101 static bool setReturnValueMessage(ito::RetVal &retVal, const QString &objName, const tErrMsg &errorMSG, PyObject *exceptionIfError = PyExc_RuntimeError, PyObject *exceptionIfWarning = PyExc_RuntimeWarning);
102 static bool setReturnValueMessage(ito::RetVal &retVal, const char *objName, const tErrMsg &errorMSG, PyObject *exceptionIfError = PyExc_RuntimeError, PyObject *exceptionIfWarning = PyExc_RuntimeWarning);
103
107 static ito::RetVal checkForPyExceptions(bool clearError = true);
108 };
109
110} //end namespace ito
111
112#endif
<
Definition param.h:95
class for parameter handling e.g. to pass parameters to plugins
Definition param.h:477
Base class for all meta-information classes.
Definition paramMeta.h:58
Definition pythonCommon.h:63
static ito::RetVal checkForPyExceptions(bool clearError=true)
Definition pythonCommon.cpp:2201
CodeCheckerMode
< mode that can be chosen for the code checker
Definition pythonCommon.h:75
@ NoCodeChecker
no code checker active
Definition pythonCommon.h:76
@ CodeCheckerPyFlakes
syntax error and further static code analysis based on PyFlakes
Definition pythonCommon.h:77
@ CodeCheckerAuto
chose Flake8 if flake8 is available, else chose PyFlakes if pyflakes is available,...
Definition pythonCommon.h:79
@ CodeCheckerFlake8
extended code checks (syntax, style, doc style, complexity...) based on Flake8
Definition pythonCommon.h:78
CodeCheckerMessageType
Definition pythonCommon.h:84
@ TypeInfo
the assigned message is displayed as information (blue dot)
Definition pythonCommon.h:85
@ TypeWarning
the assigned message is displayed as warning (orange dot)
Definition pythonCommon.h:86
@ TypeError
the assigned message is displayed as error (bug symbol)
Definition pythonCommon.h:87
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40
ito::RetVal findAndDeleteReservedInitKeyWords(PyObject *kwds, bool *enableAutoLoadParams)
Definition pythonCommon.cpp:1472
void errOutInitParams(const QVector< ito::Param > *params, const int num, const char *reason)
Definition pythonCommon.cpp:1158
ito::RetVal checkAndSetParamVal(PyObject *tempObj, ito::Param *param, int *set)
Definition pythonCommon.cpp:54
ito::RetVal createEmptyParamBaseFromParamVector(const QVector< ito::Param > *paramVecIn, QVector< ito::ParamBase > &paramVecOut)
This function searches for reserves Keywords (e.g. autoLoadParams) sets the corresponding bool parame...
ito::RetVal copyParamVector(const QVector< ito::ParamBase > *paramVecIn, QVector< ito::ParamBase > &paramVecOut)
Definition pythonCommon.cpp:1409