23 #include <boost/locale/encoding_utf.hpp> 24 #include <boost/python/extract.hpp> 28 namespace bp = boost::python;
29 using boost::locale::conv::utf_to_utf;
34 PyErr_Format(PyExc_OSError,
"Method %s not supported on wrapper file objects", __func__);
35 bp::throw_error_already_set();
39 PyErr_Format(PyExc_OSError,
"Method %s not supported on wrapper file objects", __func__);
40 bp::throw_error_already_set();
56 PyErr_Format(PyExc_IOError,
"Object is write only");
57 bp::throw_error_already_set();
62 PyErr_Format(PyExc_IOError,
"Object is write only");
63 bp::throw_error_already_set();
68 PyErr_Format(PyExc_IOError,
"Object is write only");
69 bp::throw_error_already_set();
74 PyErr_Format(PyExc_OSError,
"Method %s not supported on wrapper file objects", __func__);
75 bp::throw_error_already_set();
84 PyErr_Format(PyExc_OSError,
"Method %s not supported on wrapper file objects", __func__);
85 bp::throw_error_already_set();
90 PyErr_Format(PyExc_OSError,
"Method %s not supported on wrapper file objects", __func__);
91 bp::throw_error_already_set();
99 bp::extract<std::string> string_extractor{obj};
100 bp::extract<std::wstring> unicode_extractor{obj};
103 if (string_extractor.check()) {
104 str = string_extractor;
106 else if (unicode_extractor.check()) {
108 str = utf_to_utf<char>(unicode.
c_str(), unicode.
c_str() + unicode.
size());
111 std::string obj_type_name = bp::extract<std::string>(obj.attr(
"__class__").attr(
"__name__"));
112 PyErr_Format(PyExc_TypeError,
113 "SourceXtractor output wrapper only accepts classic strings or unicode strings, got %s",
114 obj_type_name.
c_str()
116 bp::throw_error_already_set();
131 for (
int i = 0; i < bp::len(lines); ++i) {
void info(const std::string &logMessage)