summaryrefslogtreecommitdiff
path: root/lib/python.h
blob: eb50964e155105cd8adcf836b648d60e1079a321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * python.h
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#ifndef __PYTHON_H
#define __PYTHON_H

#include <Python.h>

#include "db.h"

//***************************************************************************
// Class Python
//***************************************************************************

class Python
{
   public:

      Python(const char* aFile, const char* aFunction);
      ~Python();

      int init(const char* modulePath = 0);
      int exit();

      int execute(cDbTable* eventsDb, int namingmode, const char* tmplExpression);

      const char* getResult() { return result ? result : ""; }

   protected:

      static PyObject* eventTitle(PyObject* self, PyObject* args);
      static PyObject* eventShortText(PyObject* self, PyObject* args);
      static PyObject* eventStartTime(PyObject* self, PyObject* args);
      static PyObject* eventYear(PyObject* self, PyObject* args);
      static PyObject* eventCategory(PyObject* self, PyObject* args);

      static PyObject* episodeName(PyObject* self, PyObject* args);
      static PyObject* episodeShortName(PyObject* self, PyObject* args);
      static PyObject* episodePartName(PyObject* self, PyObject* args);
      static PyObject* extracol1(PyObject* self, PyObject* args);
      static PyObject* extracol2(PyObject* self, PyObject* args);
      static PyObject* extracol3(PyObject* self, PyObject* args);
      static PyObject* episodeSeason(PyObject* self, PyObject* args);
      static PyObject* episodePart(PyObject* self, PyObject* args);
      static PyObject* episodeNumber(PyObject* self, PyObject* args);
      static PyObject* namingMode(PyObject* self, PyObject* args);
      static PyObject* tmplExpression(PyObject* self, PyObject* args);

      void showError();

      // data

      PyObject* pModule;
      PyObject* pFunc;

      char* file;
      char* function;
      char* result;

      // static stuff

      static cDbTable* globalEventsDb;
      static int globalNamingMode;
      static const char* globalTmplExpression;
      static PyMethodDef eventMethods[];

#if PY_MAJOR_VERSION >= 3
      static PyObject* PyInitEvent() { return PyModule_Create(&Python::moduledef); }
      static PyModuleDef moduledef;
#endif
};

//***************************************************************************
#endif // __PYTHON_H