blob: b5d7d493da010f83197925b3fd132717af1f1f7a (
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
79
|
#include "python.h"
#include "ledger.h"
#include "acconf.h"
#include <boost/python.hpp>
using namespace boost::python;
namespace {
bool python_initialized = false;
bool module_initialized = false;
}
void export_amount();
void export_balance();
void export_value();
void export_journal();
void export_parser();
void export_textual();
void export_binary();
void export_qif();
#ifdef READ_GNUCASH
void export_gnucash();
#endif
void export_option();
void export_config();
void export_walk();
void export_format();
void export_valexpr();
void export_datetime();
void initialize_ledger_for_python()
{
export_amount();
export_balance();
export_value();
export_journal();
export_parser();
export_textual();
export_binary();
export_qif();
#ifdef READ_GNUCASH
export_gnucash();
#endif
export_option();
export_config();
export_walk();
export_format();
export_valexpr();
export_datetime();
module_initialized = true;
}
namespace ledger {
python_support * python_interpretor = NULL;
static struct cleanup_python {
~cleanup_python() {
if (python_initialized)
Py_Finalize();
if (python_interpretor)
delete python_interpretor;
}
} _cleanup;
void init_python()
{
if (! module_initialized) {
Py_Initialize();
python_initialized = true;
detail::init_module("ledger", &initialize_ledger_for_python);
}
python_interpretor = new python_support;
}
} // namespace ledger
|