wowool-sdk-cpp 3.5.6__tar.gz → 3.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/PKG-INFO +1 -1
- wowool_sdk_cpp-3.6.0/sdk_version.txt +1 -0
- wowool_sdk_cpp-3.6.0/version.txt +1 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool/native/core/wowool_sdk.cpp +340 -359
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool/package/lib/wowool_sdk.py +1 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool_sdk_cpp.egg-info/PKG-INFO +1 -1
- wowool_sdk_cpp-3.5.6/sdk_version.txt +0 -1
- wowool_sdk_cpp-3.5.6/version.txt +0 -1
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/MANIFEST.in +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/common_setup.py +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/install_requires.txt +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/install_requires_wowool.txt +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/long_description.md +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/pre_setup.py +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/pyproject.toml +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/setup.cfg +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/setup.py +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool/package/lib/wowool_plugin.py +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool/plugin/wowool_plugin.cpp +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool/plugin/wowool_plugin.hpp +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool_sdk_cpp.egg-info/SOURCES.txt +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool_sdk_cpp.egg-info/dependency_links.txt +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool_sdk_cpp.egg-info/not-zip-safe +0 -0
- {wowool_sdk_cpp-3.5.6 → wowool_sdk_cpp-3.6.0}/wowool_sdk_cpp.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.6.0
|
|
@@ -3,16 +3,6 @@
|
|
|
3
3
|
// Otherwise MSVC can not compile the stuff
|
|
4
4
|
/////////////////////////////////////////////////////////////////
|
|
5
5
|
#define WITH_THREAD
|
|
6
|
-
#include <Python.h>
|
|
7
|
-
#include <iostream>
|
|
8
|
-
#include <mutex>
|
|
9
|
-
#include <pybind11/functional.h>
|
|
10
|
-
#include <pybind11/pybind11.h>
|
|
11
|
-
#include <pybind11/stl.h>
|
|
12
|
-
#include <string>
|
|
13
|
-
#include <thread>
|
|
14
|
-
#include <variant>
|
|
15
|
-
#include <vector>
|
|
16
6
|
#include "wowool/analyzer/analyzer.hpp"
|
|
17
7
|
#include "wowool/analyzer/options.hpp"
|
|
18
8
|
#include "wowool/common/exception.hpp"
|
|
@@ -23,11 +13,21 @@
|
|
|
23
13
|
#include "wowool/engine/engine.hpp"
|
|
24
14
|
#include "wowool/filter/filter.hpp"
|
|
25
15
|
#include "wowool/language_identifier/language_identifier.hpp"
|
|
16
|
+
#include <Python.h>
|
|
17
|
+
#include <iostream>
|
|
18
|
+
#include <mutex>
|
|
19
|
+
#include <pybind11/functional.h>
|
|
20
|
+
#include <pybind11/pybind11.h>
|
|
21
|
+
#include <pybind11/stl.h>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <thread>
|
|
24
|
+
#include <variant>
|
|
25
|
+
#include <vector>
|
|
26
26
|
#if !defined(WIN32)
|
|
27
|
-
|
|
27
|
+
#include <signal.h>
|
|
28
28
|
#else
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
#include <thread>
|
|
30
|
+
#include <windows.h>
|
|
31
31
|
#endif
|
|
32
32
|
namespace py = pybind11;
|
|
33
33
|
|
|
@@ -38,392 +38,372 @@ namespace py = pybind11;
|
|
|
38
38
|
std::mutex global_python_mutex;
|
|
39
39
|
#define PYTHON_LOCK std::lock_guard<std::mutex> guard(global_python_mutex);
|
|
40
40
|
|
|
41
|
-
bool get_environment_bool(std::string const &env_id, bool default_value)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
return default_value;
|
|
41
|
+
bool get_environment_bool(std::string const &env_id, bool default_value) {
|
|
42
|
+
char const *value_ptr = std::getenv(env_id.c_str());
|
|
43
|
+
if (value_ptr) {
|
|
44
|
+
std::string value(value_ptr);
|
|
45
|
+
return value == "true" or value == "True";
|
|
46
|
+
}
|
|
47
|
+
return default_value;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
bool lock_gil = get_environment_bool("WOWOOL_LOCK_GIL", false);
|
|
53
51
|
|
|
54
52
|
namespace detail {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
mutable bool initial = true;
|
|
53
|
+
struct DoNotExecFirstTime {
|
|
54
|
+
mutable bool initial = true;
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
else
|
|
67
|
-
initial = false;
|
|
68
|
-
}
|
|
56
|
+
template <typename Functor> void operator()(Functor functor) const {
|
|
57
|
+
if (!initial) {
|
|
58
|
+
functor();
|
|
59
|
+
} else
|
|
60
|
+
initial = false;
|
|
61
|
+
}
|
|
69
62
|
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
void reset() { initial = true; }
|
|
64
|
+
};
|
|
72
65
|
|
|
73
66
|
} // namespace detail
|
|
74
67
|
|
|
75
|
-
std::ostream &print_string_map(std::ostream &out,
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return out;
|
|
68
|
+
std::ostream &print_string_map(std::ostream &out,
|
|
69
|
+
wowool::common::Options const &options) {
|
|
70
|
+
for (auto const &option : options) {
|
|
71
|
+
out << option.first << ":" << option.second << ",";
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
82
74
|
}
|
|
83
75
|
|
|
84
76
|
namespace tir {
|
|
85
77
|
namespace pywowool {
|
|
86
78
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
void translate(exception_t const &e)
|
|
121
|
-
{
|
|
122
|
-
PyErr_SetString(PyExc_RuntimeError, e.what());
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
wowool::common::Options convert_py_2_api_options(py::dict const &kwargs)
|
|
126
|
-
{
|
|
127
|
-
wowool::common::Options options;
|
|
128
|
-
for (auto const &item : kwargs)
|
|
129
|
-
{
|
|
130
|
-
options.emplace(py::str(item.first), py::str(item.second));
|
|
131
|
-
}
|
|
132
|
-
return options;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
std::string convert_filterset(wowool::filter::Filter const &filterset)
|
|
136
|
-
{
|
|
137
|
-
return filterset.info();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
py::dict convert_options_2_py(wowool::common::Options const &options)
|
|
141
|
-
{
|
|
142
|
-
py::dict kwargs;
|
|
143
|
-
for (auto const &item : options)
|
|
144
|
-
{
|
|
145
|
-
kwargs[py::str(item.first)] = py::str(item.second);
|
|
146
|
-
}
|
|
147
|
-
return kwargs;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// self.options["pytryoshka"] = "true"
|
|
151
|
-
|
|
152
|
-
static wowool::common::Options global_shared_engine_options = {
|
|
153
|
-
{std::string("language"), std::string("auto")},
|
|
154
|
-
// { std::string("verbose") , std::string("trace") },
|
|
155
|
-
{std::string("pytryoshka"), std::string("true")}};
|
|
156
|
-
|
|
157
|
-
static std::shared_ptr<wowool::engine::Engine>
|
|
158
|
-
global_shared_engine; //( global_shared_engine_options );
|
|
159
|
-
|
|
160
|
-
wowool::engine::Engine &get_default_engine(wowool::common::Options &options)
|
|
161
|
-
{
|
|
162
|
-
PYTHON_LOCK
|
|
163
|
-
|
|
164
|
-
if (!global_shared_engine)
|
|
165
|
-
{
|
|
166
|
-
wowool::engine::Engine *global_wowool_engine = new wowool::engine::Engine(options);
|
|
167
|
-
// std::cout << " !!!!!!!!!!!!!! Creating Global Engine" << global_wowool_engine << std::endl;
|
|
168
|
-
global_shared_engine.reset(global_wowool_engine);
|
|
169
|
-
}
|
|
170
|
-
return *global_shared_engine;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
class engine_t : public wowool::engine::Engine
|
|
174
|
-
{
|
|
175
|
-
public:
|
|
176
|
-
// typedef wowool::EngineInterface type;
|
|
177
|
-
|
|
178
|
-
typedef wowool::engine::Engine type;
|
|
179
|
-
|
|
180
|
-
// using wowool::engine::Engine::Engine;
|
|
181
|
-
|
|
182
|
-
// engine_t(wowool::engine::Engine const &&base)
|
|
183
|
-
// : wowool::engine::Engine(std::move(base))
|
|
184
|
-
// {
|
|
185
|
-
// std::cout << "PLUGIN wowool::engine::Engine(wowool::engine::Engine const &&base)" << this << std::endl;
|
|
186
|
-
// }
|
|
187
|
-
|
|
188
|
-
// engine_t(wowool::engine::Engine const &&base, py::dict const &kwarg)
|
|
189
|
-
// : wowool::engine::Engine(tir::pywowool::convert_py_2_api_options(kwarg))
|
|
190
|
-
// {
|
|
191
|
-
// std::cout << "PLUGIN wowool::engine::Engine(wowool::engine::Engine const &&base, py::dict const &kwarg)" << this << std::endl;
|
|
192
|
-
// }
|
|
193
|
-
|
|
194
|
-
// we need this one to be able to create multi_process objects.
|
|
195
|
-
engine_t(py::dict const &kwarg)
|
|
196
|
-
: wowool::engine::Engine(tir::pywowool::convert_py_2_api_options(kwarg))
|
|
197
|
-
{
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
class lid_t : public wowool::language_identifier::LanguageIdentifier
|
|
202
|
-
{
|
|
203
|
-
public:
|
|
204
|
-
typedef wowool::language_identifier::LanguageIdentifier type;
|
|
205
|
-
|
|
206
|
-
using wowool::language_identifier::LanguageIdentifier::LanguageIdentifier;
|
|
207
|
-
|
|
208
|
-
lid_t(wowool::language_identifier::LanguageIdentifier const &&base)
|
|
209
|
-
: wowool::language_identifier::LanguageIdentifier(std::move(base)) {}
|
|
210
|
-
|
|
211
|
-
lid_t(wowool::analyzer::Engine const &engine, py::dict const &kwarg)
|
|
212
|
-
: wowool::language_identifier::LanguageIdentifier(engine, tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
213
|
-
|
|
214
|
-
lid_t(py::dict const &kwarg)
|
|
215
|
-
: wowool::language_identifier::LanguageIdentifier(tir::pywowool::get_default_engine(global_shared_engine_options), tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
class domain_t : public wowool::domain::Domain
|
|
219
|
-
{
|
|
220
|
-
public:
|
|
221
|
-
typedef wowool::domain::Domain type;
|
|
222
|
-
|
|
223
|
-
using wowool::domain::Domain::Domain;
|
|
224
|
-
|
|
225
|
-
domain_t(wowool::domain::Domain const &&base)
|
|
226
|
-
: wowool::domain::Domain(std::move(base)) {}
|
|
227
|
-
|
|
228
|
-
domain_t(wowool::analyzer::Engine const &engine, std::string const domain_descriptor, py::dict const &kwarg)
|
|
229
|
-
: wowool::domain::Domain(engine, domain_descriptor, tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
230
|
-
|
|
231
|
-
// we need this one to be able to create multi_process objects.
|
|
232
|
-
domain_t(py::dict const &kwarg)
|
|
233
|
-
: wowool::domain::Domain(
|
|
234
|
-
tir::pywowool::get_default_engine(global_shared_engine_options),
|
|
235
|
-
kwarg["name"].cast<std::string>(),
|
|
236
|
-
tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
237
|
-
|
|
238
|
-
// wowool::analyzer::Results process(wowool::analyzer::Results const document)
|
|
239
|
-
// {
|
|
240
|
-
// char *p = 0;
|
|
241
|
-
// *p = 0;
|
|
242
|
-
// std::cout << "PLUGIN domain_t::process" << std::endl;
|
|
243
|
-
// // py::gil_scoped_release release; // Release the GIL
|
|
244
|
-
// return (*static_cast<wowool::domain::Domain const *>(this))(document);
|
|
245
|
-
// };
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
wowool::filter::FilterCollection string2filterset(std::string const &filter_str)
|
|
249
|
-
{
|
|
250
|
-
auto filter_vector = wowool::common::split(filter_str, ',');
|
|
251
|
-
return wowool::filter::FilterCollection(filter_vector.begin(), filter_vector.end());
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
class filter_t : public wowool::filter::Filter
|
|
255
|
-
{
|
|
256
|
-
public:
|
|
257
|
-
typedef wowool::filter::Filter type;
|
|
258
|
-
|
|
259
|
-
using wowool::filter::Filter::Filter;
|
|
260
|
-
|
|
261
|
-
filter_t(wowool::filter::Filter const &&base)
|
|
262
|
-
: wowool::filter::Filter(std::move(base)) {}
|
|
263
|
-
|
|
264
|
-
filter_t(wowool::filter::FilterCollection const &filterset)
|
|
265
|
-
: wowool::filter::Filter(filterset), _filterset(filterset) {}
|
|
266
|
-
|
|
267
|
-
filter_t(std::string const filterset)
|
|
268
|
-
: wowool::filter::Filter(filterset), _filterset(string2filterset(filterset)) {}
|
|
79
|
+
class exception_t : public std::exception {
|
|
80
|
+
private:
|
|
81
|
+
std::string message;
|
|
82
|
+
std::string extraData;
|
|
83
|
+
|
|
84
|
+
public:
|
|
85
|
+
exception_t(std::string message_, std::string extraData_)
|
|
86
|
+
: message(message_), extraData(extraData_) {}
|
|
87
|
+
// TODO: declare this nothrow
|
|
88
|
+
~exception_t() throw() {}
|
|
89
|
+
const char *what() const throw() { return message.c_str(); }
|
|
90
|
+
std::string getMessage() { return message; }
|
|
91
|
+
std::string getExtraData() { return extraData; }
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
class exception_json_t : public std::exception {
|
|
95
|
+
private:
|
|
96
|
+
std::string json_data;
|
|
97
|
+
|
|
98
|
+
public:
|
|
99
|
+
exception_json_t(std::string json_data_) : json_data(json_data_) {}
|
|
100
|
+
// TODO: declare this nothrow
|
|
101
|
+
~exception_json_t() throw() {}
|
|
102
|
+
const char *what() const throw() { return json_data.c_str(); }
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
void translate(exception_json_t const &e) {
|
|
106
|
+
PyErr_SetString(PyExc_RuntimeError, e.what());
|
|
107
|
+
}
|
|
108
|
+
void translate(exception_t const &e) {
|
|
109
|
+
PyErr_SetString(PyExc_RuntimeError, e.what());
|
|
110
|
+
}
|
|
269
111
|
|
|
270
|
-
|
|
271
|
-
|
|
112
|
+
wowool::common::Options convert_py_2_api_options(py::dict const &kwargs) {
|
|
113
|
+
wowool::common::Options options;
|
|
114
|
+
for (auto const &item : kwargs) {
|
|
115
|
+
options.emplace(py::str(item.first), py::str(item.second));
|
|
116
|
+
}
|
|
117
|
+
return options;
|
|
118
|
+
}
|
|
272
119
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
typedef wowool::analyzer::Results type;
|
|
120
|
+
std::string convert_filterset(wowool::filter::Filter const &filterset) {
|
|
121
|
+
return filterset.info();
|
|
122
|
+
}
|
|
277
123
|
|
|
278
|
-
|
|
124
|
+
py::dict convert_options_2_py(wowool::common::Options const &options) {
|
|
125
|
+
py::dict kwargs;
|
|
126
|
+
for (auto const &item : options) {
|
|
127
|
+
kwargs[py::str(item.first)] = py::str(item.second);
|
|
128
|
+
}
|
|
129
|
+
return kwargs;
|
|
130
|
+
}
|
|
279
131
|
|
|
280
|
-
|
|
281
|
-
: wowool::analyzer::Results(std::move(base)) {}
|
|
282
|
-
};
|
|
132
|
+
// self.options["pytryoshka"] = "true"
|
|
283
133
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
py::dict _kwargs;
|
|
134
|
+
static wowool::common::Options global_shared_engine_options = {
|
|
135
|
+
{std::string("language"), std::string("auto")},
|
|
136
|
+
// { std::string("verbose") , std::string("trace") },
|
|
137
|
+
{std::string("pytryoshka"), std::string("true")}};
|
|
289
138
|
|
|
290
|
-
|
|
291
|
-
|
|
139
|
+
static std::shared_ptr<wowool::engine::Engine>
|
|
140
|
+
global_shared_engine; //( global_shared_engine_options );
|
|
292
141
|
|
|
293
|
-
|
|
294
|
-
|
|
142
|
+
wowool::engine::Engine &get_default_engine(wowool::common::Options &options) {
|
|
143
|
+
PYTHON_LOCK
|
|
295
144
|
|
|
296
|
-
|
|
297
|
-
|
|
145
|
+
if (!global_shared_engine) {
|
|
146
|
+
wowool::engine::Engine *global_wowool_engine =
|
|
147
|
+
new wowool::engine::Engine(options);
|
|
148
|
+
// std::cout << " !!!!!!!!!!!!!! Creating Global Engine" <<
|
|
149
|
+
// global_wowool_engine << std::endl;
|
|
150
|
+
global_shared_engine.reset(global_wowool_engine);
|
|
151
|
+
}
|
|
152
|
+
return *global_shared_engine;
|
|
153
|
+
}
|
|
298
154
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
155
|
+
class engine_t : public wowool::engine::Engine {
|
|
156
|
+
public:
|
|
157
|
+
// typedef wowool::EngineInterface type;
|
|
158
|
+
|
|
159
|
+
typedef wowool::engine::Engine type;
|
|
160
|
+
|
|
161
|
+
// using wowool::engine::Engine::Engine;
|
|
162
|
+
|
|
163
|
+
// engine_t(wowool::engine::Engine const &&base)
|
|
164
|
+
// : wowool::engine::Engine(std::move(base))
|
|
165
|
+
// {
|
|
166
|
+
// std::cout << "PLUGIN wowool::engine::Engine(wowool::engine::Engine const
|
|
167
|
+
// &&base)" << this << std::endl;
|
|
168
|
+
// }
|
|
169
|
+
|
|
170
|
+
// engine_t(wowool::engine::Engine const &&base, py::dict const &kwarg)
|
|
171
|
+
// : wowool::engine::Engine(tir::pywowool::convert_py_2_api_options(kwarg))
|
|
172
|
+
// {
|
|
173
|
+
// std::cout << "PLUGIN wowool::engine::Engine(wowool::engine::Engine const
|
|
174
|
+
// &&base, py::dict const &kwarg)" << this << std::endl;
|
|
175
|
+
// }
|
|
176
|
+
|
|
177
|
+
// we need this one to be able to create multi_process objects.
|
|
178
|
+
engine_t(py::dict const &kwarg)
|
|
179
|
+
: wowool::engine::Engine(tir::pywowool::convert_py_2_api_options(kwarg)) {
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
class lid_t : public wowool::language_identifier::LanguageIdentifier {
|
|
184
|
+
public:
|
|
185
|
+
typedef wowool::language_identifier::LanguageIdentifier type;
|
|
186
|
+
|
|
187
|
+
using wowool::language_identifier::LanguageIdentifier::LanguageIdentifier;
|
|
188
|
+
|
|
189
|
+
lid_t(wowool::language_identifier::LanguageIdentifier const &&base)
|
|
190
|
+
: wowool::language_identifier::LanguageIdentifier(std::move(base)) {}
|
|
191
|
+
|
|
192
|
+
lid_t(wowool::analyzer::Engine const &engine, py::dict const &kwarg)
|
|
193
|
+
: wowool::language_identifier::LanguageIdentifier(
|
|
194
|
+
engine, tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
195
|
+
|
|
196
|
+
lid_t(py::dict const &kwarg)
|
|
197
|
+
: wowool::language_identifier::LanguageIdentifier(
|
|
198
|
+
tir::pywowool::get_default_engine(global_shared_engine_options),
|
|
199
|
+
tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
class domain_t : public wowool::domain::Domain {
|
|
203
|
+
public:
|
|
204
|
+
typedef wowool::domain::Domain type;
|
|
205
|
+
|
|
206
|
+
using wowool::domain::Domain::Domain;
|
|
207
|
+
|
|
208
|
+
domain_t(wowool::domain::Domain const &&base)
|
|
209
|
+
: wowool::domain::Domain(std::move(base)) {}
|
|
210
|
+
|
|
211
|
+
domain_t(wowool::analyzer::Engine const &engine,
|
|
212
|
+
std::string const domain_descriptor, py::dict const &kwarg)
|
|
213
|
+
: wowool::domain::Domain(engine, domain_descriptor,
|
|
214
|
+
tir::pywowool::convert_py_2_api_options(kwarg)) {
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// we need this one to be able to create multi_process objects.
|
|
218
|
+
domain_t(py::dict const &kwarg)
|
|
219
|
+
: wowool::domain::Domain(
|
|
220
|
+
tir::pywowool::get_default_engine(global_shared_engine_options),
|
|
221
|
+
kwarg["name"].cast<std::string>(),
|
|
222
|
+
tir::pywowool::convert_py_2_api_options(kwarg)) {}
|
|
223
|
+
|
|
224
|
+
// wowool::analyzer::Results process(wowool::analyzer::Results const document)
|
|
225
|
+
// {
|
|
226
|
+
// char *p = 0;
|
|
227
|
+
// *p = 0;
|
|
228
|
+
// std::cout << "PLUGIN domain_t::process" << std::endl;
|
|
229
|
+
// // py::gil_scoped_release release; // Release the GIL
|
|
230
|
+
// return (*static_cast<wowool::domain::Domain const *>(this))(document);
|
|
231
|
+
// };
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
wowool::filter::FilterCollection
|
|
235
|
+
string2filterset(std::string const &filter_str) {
|
|
236
|
+
auto filter_vector = wowool::common::split(filter_str, ',');
|
|
237
|
+
return wowool::filter::FilterCollection(filter_vector.begin(),
|
|
238
|
+
filter_vector.end());
|
|
239
|
+
}
|
|
320
240
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
241
|
+
class filter_t : public wowool::filter::Filter {
|
|
242
|
+
public:
|
|
243
|
+
typedef wowool::filter::Filter type;
|
|
244
|
+
|
|
245
|
+
using wowool::filter::Filter::Filter;
|
|
246
|
+
|
|
247
|
+
filter_t(wowool::filter::Filter const &&base)
|
|
248
|
+
: wowool::filter::Filter(std::move(base)) {}
|
|
249
|
+
|
|
250
|
+
filter_t(wowool::filter::FilterCollection const &filterset)
|
|
251
|
+
: wowool::filter::Filter(filterset), _filterset(filterset) {}
|
|
252
|
+
|
|
253
|
+
filter_t(std::string const filterset)
|
|
254
|
+
: wowool::filter::Filter(filterset),
|
|
255
|
+
_filterset(string2filterset(filterset)) {}
|
|
256
|
+
|
|
257
|
+
wowool::filter::FilterCollection const _filterset;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
class results_t : public wowool::analyzer::Results {
|
|
261
|
+
public:
|
|
262
|
+
typedef wowool::analyzer::Results type;
|
|
263
|
+
|
|
264
|
+
using wowool::analyzer::Results::Results;
|
|
265
|
+
|
|
266
|
+
results_t(wowool::analyzer::Results const &&base)
|
|
267
|
+
: wowool::analyzer::Results(std::move(base)) {}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
class analyzer_t : public wowool::analyzer::Analyzer {
|
|
271
|
+
public:
|
|
272
|
+
typedef wowool::analyzer::Analyzer type;
|
|
273
|
+
py::dict _kwargs;
|
|
274
|
+
|
|
275
|
+
using wowool::analyzer::Analyzer::Analyzer;
|
|
276
|
+
using wowool::analyzer::Analyzer::operator();
|
|
277
|
+
|
|
278
|
+
analyzer_t(wowool::analyzer::Analyzer const &&base)
|
|
279
|
+
: wowool::analyzer::Analyzer(std::move(base)) {}
|
|
280
|
+
|
|
281
|
+
analyzer_t(wowool::analyzer::Engine const &engine, py::dict const &kwarg)
|
|
282
|
+
: wowool::analyzer::Analyzer(
|
|
283
|
+
engine, tir::pywowool::convert_py_2_api_options(kwarg)),
|
|
284
|
+
_kwargs(kwarg) {}
|
|
285
|
+
|
|
286
|
+
std::string
|
|
287
|
+
process_return_string(std::string const &document,
|
|
288
|
+
wowool::common::Options const &json_options) {
|
|
289
|
+
std::string ret_val;
|
|
290
|
+
// std::cout << "options:" ; print_string_map(std::cout , json_options);
|
|
291
|
+
// std::cout << std::endl;
|
|
292
|
+
auto results = (*this)(document, json_options);
|
|
293
|
+
return results.to_json();
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
std::string pipeline_expand(std::string const &pipeline,
|
|
298
|
+
std::string const &paths_str, bool file_access,
|
|
299
|
+
bool allow_dev_versions,
|
|
300
|
+
std::string const &pipeline_language) {
|
|
301
|
+
try {
|
|
302
|
+
std::vector<std::string> paths = wowool::common::split(paths_str, ',');
|
|
303
|
+
return wowool::engine::expand_pipeline(
|
|
304
|
+
pipeline, paths, file_access, allow_dev_versions, pipeline_language);
|
|
305
|
+
} catch (wowool::common::JsonException const &ex) {
|
|
306
|
+
throw exception_json_t(ex.what());
|
|
307
|
+
}
|
|
308
|
+
}
|
|
325
309
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
for (auto const &domain_descriptor : domains)
|
|
334
|
-
{
|
|
335
|
-
std::vector<std::string> groups;
|
|
336
|
-
std::string domain = domain_descriptor;
|
|
337
|
-
wowool::domain::get_domain_concepts(domain, groups);
|
|
338
|
-
std::copy(groups.begin(), groups.end(), std::back_inserter(all_groups));
|
|
339
|
-
}
|
|
340
|
-
} catch (std::exception const &ex)
|
|
341
|
-
{
|
|
342
|
-
throw exception_t(ex.what(), "");
|
|
343
|
-
}
|
|
310
|
+
std::string pipeline_parse(std::string const &pipeline) {
|
|
311
|
+
try {
|
|
312
|
+
return wowool::engine::parse_pipeline(pipeline);
|
|
313
|
+
} catch (wowool::common::JsonException const &ex) {
|
|
314
|
+
throw exception_json_t(ex.what());
|
|
315
|
+
}
|
|
316
|
+
}
|
|
344
317
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
detail::DoNotExecFirstTime dneft;
|
|
349
|
-
for (auto const &concept : all_groups)
|
|
350
|
-
{
|
|
351
|
-
if (concept.empty())
|
|
352
|
-
continue;
|
|
318
|
+
bool is_valid_version_format(std::string const &version) {
|
|
319
|
+
return wowool::common::is_valid_version_format(version);
|
|
320
|
+
}
|
|
353
321
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
322
|
+
std::string get_domain_info(std::string const domains_str) {
|
|
323
|
+
std::vector<std::string> all_groups;
|
|
324
|
+
std::vector<std::string> domains = wowool::common::split(domains_str, ',');
|
|
325
|
+
std::stringstream json;
|
|
326
|
+
try {
|
|
327
|
+
for (auto const &domain_descriptor : domains) {
|
|
328
|
+
std::vector<std::string> groups;
|
|
329
|
+
std::string domain = domain_descriptor;
|
|
330
|
+
wowool::domain::get_domain_concepts(domain, groups);
|
|
331
|
+
std::copy(groups.begin(), groups.end(), std::back_inserter(all_groups));
|
|
332
|
+
}
|
|
333
|
+
} catch (std::exception const &ex) {
|
|
334
|
+
throw exception_t(ex.what(), "");
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (!all_groups.empty()) {
|
|
338
|
+
json << "[";
|
|
339
|
+
detail::DoNotExecFirstTime dneft;
|
|
340
|
+
for (auto const &concept : all_groups) {
|
|
341
|
+
if (concept.empty())
|
|
342
|
+
continue;
|
|
343
|
+
|
|
344
|
+
dneft([&json]() { json << ","; });
|
|
345
|
+
json << "\"" << concept << "\"";
|
|
346
|
+
}
|
|
347
|
+
json << "]";
|
|
348
|
+
return json.str();
|
|
349
|
+
} else {
|
|
350
|
+
json << "[]";
|
|
351
|
+
}
|
|
352
|
+
return json.str();
|
|
353
|
+
}
|
|
366
354
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
355
|
+
void print_log_message(unsigned short id, char const *msg) {
|
|
356
|
+
std::cout << msg << std::endl;
|
|
357
|
+
}
|
|
371
358
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
throw exception_t(e.what(), "");
|
|
384
|
-
}
|
|
385
|
-
}
|
|
359
|
+
std::string compile_domain(std::string const domain_descriptor,
|
|
360
|
+
py::dict const &kwargs) {
|
|
361
|
+
try {
|
|
362
|
+
auto options = convert_py_2_api_options(kwargs);
|
|
363
|
+
return wowool::domain::compile_domain(options);
|
|
364
|
+
} catch (wowool::common::Exception &ex) {
|
|
365
|
+
throw exception_t(ex.what(), "");
|
|
366
|
+
} catch (std::exception const &e) {
|
|
367
|
+
throw exception_t(e.what(), "");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
386
370
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
};
|
|
371
|
+
struct options_t {
|
|
372
|
+
static const std::string language;
|
|
373
|
+
};
|
|
391
374
|
|
|
392
|
-
|
|
375
|
+
const std::string options_t::language = wowool::analyzer::option::language;
|
|
393
376
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
377
|
+
auto __exit__callback = []() {
|
|
378
|
+
PYTHON_LOCK
|
|
379
|
+
global_shared_engine.reset();
|
|
380
|
+
};
|
|
398
381
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
std::function<void(unsigned short, const char *)> logit;
|
|
382
|
+
struct PyLog {
|
|
383
|
+
std::function<void(unsigned short, const char *)> logit;
|
|
402
384
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
385
|
+
PyLog(std::function<void(unsigned short, const char *)> logit_)
|
|
386
|
+
: logit(logit_) {}
|
|
387
|
+
};
|
|
406
388
|
|
|
407
|
-
|
|
389
|
+
std::function<void(int, std::string)> pylogit;
|
|
408
390
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
}
|
|
391
|
+
void global_logger_fn(unsigned short id, const char *msg) {
|
|
392
|
+
if (pylogit) {
|
|
393
|
+
pylogit(id, std::string(msg));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
416
396
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
397
|
+
void add_logger(unsigned short id, std::string level,
|
|
398
|
+
const std::function<void(int, std::string)> logit) {
|
|
399
|
+
pylogit = logit;
|
|
400
|
+
wowool::logging::add_logger(id, level, global_logger_fn);
|
|
401
|
+
}
|
|
422
402
|
|
|
423
|
-
|
|
403
|
+
void unset_logger() { pylogit = nullptr; }
|
|
424
404
|
|
|
425
|
-
}
|
|
426
|
-
} // namespace tir
|
|
405
|
+
} // namespace pywowool
|
|
406
|
+
} // namespace tir
|
|
427
407
|
|
|
428
408
|
// clang-format off
|
|
429
409
|
|
|
@@ -444,6 +424,7 @@ PYBIND11_MODULE(_wowool_sdk, m)
|
|
|
444
424
|
m.add_object("_cleanup", py::capsule(tir::pywowool::__exit__callback));
|
|
445
425
|
m.def("get_domain_info", tir::pywowool::get_domain_info);
|
|
446
426
|
m.def("pipeline_expand", tir::pywowool::pipeline_expand);
|
|
427
|
+
m.def("pipeline_parse", tir::pywowool::pipeline_parse);
|
|
447
428
|
m.def("is_valid_version_format", tir::pywowool::is_valid_version_format);
|
|
448
429
|
m.def("compile_domain", tir::pywowool::compile_domain);
|
|
449
430
|
m.def("add_logger", tir::pywowool::add_logger);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.1.2
|
wowool_sdk_cpp-3.5.6/version.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.5.6
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|