Skip to content
Browse files

fixed add_page issues

  • Loading branch information...
1 parent 9ec1a1d commit 852fd9dc8cfbd2d1dc48e5242fefe7ab98a91528 @mreiferson committed Nov 24, 2010
Showing with 739 additions and 311 deletions.
  1. +6 −1 test_pdf.py
  2. +697 −296 wkhtmltox.c
  3. +36 −14 wkhtmltox.pyx
View
7 test_pdf.py
@@ -1,7 +1,12 @@
import wkhtmltox
pdf = wkhtmltox.Pdf()
-pdf.set_global_setting('out', 'test.pdf')
+pdf.set_global_setting('out', 'one.pdf')
pdf.add_page({'page': 'http://www.visionaryrenesis.com'})
pdf.add_page({'page': 'http://www.google.com'})
pdf.convert()
+
+pdf = wkhtmltox.Pdf()
+pdf.set_global_setting('out', 'two.pdf')
+pdf.add_page({'page': 'http://www.tweakers.net'})
+pdf.convert()
View
993 wkhtmltox.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.13 on Sat Oct 2 18:29:01 2010 */
+/* Generated by Cython 0.13 on Wed Nov 24 14:46:56 2010 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -276,22 +276,21 @@ static const char *__pyx_f[] = {
/* Type declarations */
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":56
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":59
+ * cdef int wkhtmltoimage_is_init = 0
*
- *
- * cdef class Pdf: # <<<<<<<<<<<<<<
+ * cdef class _Pdf: # <<<<<<<<<<<<<<
* cdef wkhtmltopdf_global_settings *_c_global_settings
- * cdef wkhtmltopdf_object_settings *_c_object_settings
+ * cdef bint last_http_error_code
*/
-struct __pyx_obj_9wkhtmltox_Pdf {
+struct __pyx_obj_9wkhtmltox__Pdf {
PyObject_HEAD
struct wkhtmltopdf_global_settings *_c_global_settings;
- struct wkhtmltopdf_object_settings *_c_object_settings;
int last_http_error_code;
};
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":103
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":121
*
*
* cdef class Image: # <<<<<<<<<<<<<<
@@ -351,6 +350,8 @@ struct __pyx_obj_9wkhtmltox_Image {
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
@@ -362,6 +363,13 @@ static void __Pyx_RaiseDoubleKeywordsError(
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
+
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
+
+static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
+static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
+
static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
if (likely(PyList_CheckExact(L))) {
if (PyList_Append(L, x) < 0) return NULL;
@@ -378,12 +386,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
}
}
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
-static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
+static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, const char *modname); /*proto*/
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
@@ -422,126 +425,141 @@ static void __Pyx_AddTraceback(const char *funcname); /*proto*/
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from wkhtmltox */
-static PyTypeObject *__pyx_ptype_9wkhtmltox_Pdf = 0;
+static PyTypeObject *__pyx_ptype_9wkhtmltox__Pdf = 0;
static PyTypeObject *__pyx_ptype_9wkhtmltox_Image = 0;
+static int __pyx_v_9wkhtmltox_wkhtmltopdf_is_init;
+static int __pyx_v_9wkhtmltox_wkhtmltoimage_is_init;
#define __Pyx_MODULE_NAME "wkhtmltox"
int __pyx_module_is_main_wkhtmltox = 0;
/* Implementation of wkhtmltox */
+static PyObject *__pyx_builtin_getattr;
static char __pyx_k_1[] = "last_http_error_code";
+static char __pyx_k__Pdf[] = "Pdf";
+static char __pyx_k___pdf[] = "_pdf";
static char __pyx_k__name[] = "name";
+static char __pyx_k__self[] = "self";
static char __pyx_k__pages[] = "pages";
static char __pyx_k__value[] = "value";
+static char __pyx_k__convert[] = "convert";
+static char __pyx_k__getattr[] = "getattr";
+static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
+static char __pyx_k__add_page[] = "add_page";
+static char __pyx_k__settings[] = "settings";
static char __pyx_k__iteritems[] = "iteritems";
+static char __pyx_k____getattr__[] = "__getattr__";
static char __pyx_k___c_global_settings[] = "_c_global_settings";
-static char __pyx_k___c_object_settings[] = "_c_object_settings";
static PyObject *__pyx_n_s_1;
+static PyObject *__pyx_n_s__Pdf;
+static PyObject *__pyx_n_s____getattr__;
+static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___c_global_settings;
-static PyObject *__pyx_n_s___c_object_settings;
+static PyObject *__pyx_n_s___pdf;
+static PyObject *__pyx_n_s__add_page;
+static PyObject *__pyx_n_s__convert;
+static PyObject *__pyx_n_s__getattr;
static PyObject *__pyx_n_s__iteritems;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__pages;
+static PyObject *__pyx_n_s__self;
+static PyObject *__pyx_n_s__settings;
static PyObject *__pyx_n_s__value;
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":62
- * pages = []
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":63
+ * cdef bint last_http_error_code
*
* def __cinit__(self): # <<<<<<<<<<<<<<
- * wkhtmltopdf_init(0)
- * self._c_global_settings = wkhtmltopdf_create_global_settings()
+ * global wkhtmltopdf_is_init
+ * if not wkhtmltopdf_is_init:
*/
-static int __pyx_pf_9wkhtmltox_3Pdf___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pf_9wkhtmltox_3Pdf___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static int __pyx_pf_9wkhtmltox_4_Pdf___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9wkhtmltox_4_Pdf___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
int __pyx_r;
+ int __pyx_t_1;
__Pyx_RefNannySetupContext("__cinit__");
if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
__Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":63
- *
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":65
* def __cinit__(self):
- * wkhtmltopdf_init(0) # <<<<<<<<<<<<<<
- * self._c_global_settings = wkhtmltopdf_create_global_settings()
- * self._c_object_settings = wkhtmltopdf_create_object_settings()
+ * global wkhtmltopdf_is_init
+ * if not wkhtmltopdf_is_init: # <<<<<<<<<<<<<<
+ * wkhtmltopdf_is_init = wkhtmltopdf_init(0)
+ *
*/
- wkhtmltopdf_init(0);
+ __pyx_t_1 = (!__pyx_v_9wkhtmltox_wkhtmltopdf_is_init);
+ if (__pyx_t_1) {
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":64
- * def __cinit__(self):
- * wkhtmltopdf_init(0)
- * self._c_global_settings = wkhtmltopdf_create_global_settings() # <<<<<<<<<<<<<<
- * self._c_object_settings = wkhtmltopdf_create_object_settings()
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":66
+ * global wkhtmltopdf_is_init
+ * if not wkhtmltopdf_is_init:
+ * wkhtmltopdf_is_init = wkhtmltopdf_init(0) # <<<<<<<<<<<<<<
*
+ * self._c_global_settings = wkhtmltopdf_create_global_settings()
*/
- ((struct __pyx_obj_9wkhtmltox_Pdf *)__pyx_v_self)->_c_global_settings = wkhtmltopdf_create_global_settings();
+ __pyx_v_9wkhtmltox_wkhtmltopdf_is_init = wkhtmltopdf_init(0);
+ goto __pyx_L5;
+ }
+ __pyx_L5:;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":65
- * wkhtmltopdf_init(0)
- * self._c_global_settings = wkhtmltopdf_create_global_settings()
- * self._c_object_settings = wkhtmltopdf_create_object_settings() # <<<<<<<<<<<<<<
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":68
+ * wkhtmltopdf_is_init = wkhtmltopdf_init(0)
+ *
+ * self._c_global_settings = wkhtmltopdf_create_global_settings() # <<<<<<<<<<<<<<
*
* def __dealloc__(self):
*/
- ((struct __pyx_obj_9wkhtmltox_Pdf *)__pyx_v_self)->_c_object_settings = wkhtmltopdf_create_object_settings();
+ ((struct __pyx_obj_9wkhtmltox__Pdf *)__pyx_v_self)->_c_global_settings = wkhtmltopdf_create_global_settings();
__pyx_r = 0;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":67
- * self._c_object_settings = wkhtmltopdf_create_object_settings()
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":70
+ * self._c_global_settings = wkhtmltopdf_create_global_settings()
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
- * wkhtmltopdf_deinit();
- *
+ * pass
+ * #wkhtmltopdf_deinit();
*/
-static void __pyx_pf_9wkhtmltox_3Pdf___dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9wkhtmltox_3Pdf___dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pf_9wkhtmltox_4_Pdf___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9wkhtmltox_4_Pdf___dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannySetupContext("__dealloc__");
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":68
- *
- * def __dealloc__(self):
- * wkhtmltopdf_deinit(); # <<<<<<<<<<<<<<
- *
- * def version(self):
- */
- wkhtmltopdf_deinit();
-
__Pyx_RefNannyFinishContext();
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":70
- * wkhtmltopdf_deinit();
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":74
+ * #wkhtmltopdf_deinit();
*
* def version(self): # <<<<<<<<<<<<<<
* return wkhtmltopdf_version();
*
*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_version(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_version(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9wkhtmltox_4_Pdf_version(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pf_9wkhtmltox_4_Pdf_version(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = NULL;
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("version");
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":71
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":75
*
* def version(self):
* return wkhtmltopdf_version(); # <<<<<<<<<<<<<<
*
* def set_global_setting(self, char *name, char *value):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyBytes_FromString(wkhtmltopdf_version()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(wkhtmltopdf_version()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -551,24 +569,24 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_version(PyObject *__pyx_v_self, CYTHON
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("wkhtmltox.Pdf.version");
+ __Pyx_AddTraceback("wkhtmltox._Pdf.version");
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":73
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":77
* return wkhtmltopdf_version();
*
* def set_global_setting(self, char *name, char *value): # <<<<<<<<<<<<<<
* return wkhtmltopdf_set_global_setting(self._c_global_settings, name, value)
*
*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_set_global_setting(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_set_global_setting(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9wkhtmltox_4_Pdf_set_global_setting(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_9wkhtmltox_4_Pdf_set_global_setting(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
char *__pyx_v_name;
char *__pyx_v_value;
PyObject *__pyx_r = NULL;
@@ -593,38 +611,38 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_set_global_setting(PyObject *__pyx_v_s
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
if (likely(values[1])) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("set_global_setting", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("set_global_setting", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_global_setting") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_global_setting") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
- __pyx_v_name = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- __pyx_v_value = PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_name = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_value = PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
- __pyx_v_name = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- __pyx_v_value = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_name = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_value = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("set_global_setting", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("set_global_setting", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
- __Pyx_AddTraceback("wkhtmltox.Pdf.set_global_setting");
+ __Pyx_AddTraceback("wkhtmltox._Pdf.set_global_setting");
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":74
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":78
*
* def set_global_setting(self, char *name, char *value):
* return wkhtmltopdf_set_global_setting(self._c_global_settings, name, value) # <<<<<<<<<<<<<<
*
- * def add_page(self, settings):
+ * def convert(self, pages):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(wkhtmltopdf_set_global_setting(((struct __pyx_obj_9wkhtmltox_Pdf *)__pyx_v_self)->_c_global_settings, __pyx_v_name, __pyx_v_value)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyBool_FromLong(wkhtmltopdf_set_global_setting(((struct __pyx_obj_9wkhtmltox__Pdf *)__pyx_v_self)->_c_global_settings, __pyx_v_name, __pyx_v_value)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -634,76 +652,34 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_set_global_setting(PyObject *__pyx_v_s
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("wkhtmltox.Pdf.set_global_setting");
+ __Pyx_AddTraceback("wkhtmltox._Pdf.set_global_setting");
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":76
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":80
* return wkhtmltopdf_set_global_setting(self._c_global_settings, name, value)
*
- * def add_page(self, settings): # <<<<<<<<<<<<<<
- * self.pages.append(settings)
- *
- */
-
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_add_page(PyObject *__pyx_v_self, PyObject *__pyx_v_settings); /*proto*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_add_page(PyObject *__pyx_v_self, PyObject *__pyx_v_settings) {
- PyObject *__pyx_r = NULL;
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- __Pyx_RefNannySetupContext("add_page");
-
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":77
- *
- * def add_page(self, settings):
- * self.pages.append(settings) # <<<<<<<<<<<<<<
- *
- * def convert(self):
- */
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pages); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_settings); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("wkhtmltox.Pdf.add_page");
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":79
- * self.pages.append(settings)
- *
- * def convert(self): # <<<<<<<<<<<<<<
+ * def convert(self, pages): # <<<<<<<<<<<<<<
* cdef wkhtmltopdf_converter *c
* cdef wkhtmltopdf_object_settings *os
*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9wkhtmltox_4_Pdf_convert(PyObject *__pyx_v_self, PyObject *__pyx_v_pages); /*proto*/
+static PyObject *__pyx_pf_9wkhtmltox_4_Pdf_convert(PyObject *__pyx_v_self, PyObject *__pyx_v_pages) {
struct wkhtmltopdf_converter *__pyx_v_c;
struct wkhtmltopdf_object_settings *__pyx_v_os;
PyObject *__pyx_v_page;
PyObject *__pyx_v_k;
PyObject *__pyx_v_v;
int __pyx_v_ret;
PyObject *__pyx_r = NULL;
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t __pyx_t_2;
- int __pyx_t_3;
+ Py_ssize_t __pyx_t_1;
+ int __pyx_t_2;
+ PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
Py_ssize_t __pyx_t_5;
PyObject *__pyx_t_6 = NULL;
@@ -717,120 +693,114 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON
__pyx_v_k = Py_None; __Pyx_INCREF(Py_None);
__pyx_v_v = Py_None; __Pyx_INCREF(Py_None);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":83
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":84
* cdef wkhtmltopdf_object_settings *os
*
- * if not len(self.pages): # <<<<<<<<<<<<<<
+ * if not len(pages): # <<<<<<<<<<<<<<
* return False
*
*/
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pages); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = (!__pyx_t_2);
- if (__pyx_t_3) {
+ __pyx_t_1 = PyObject_Length(__pyx_v_pages); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = (!__pyx_t_1);
+ if (__pyx_t_2) {
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":84
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":85
*
- * if not len(self.pages):
+ * if not len(pages):
* return False # <<<<<<<<<<<<<<
*
* c = wkhtmltopdf_create_converter(self._c_global_settings)
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
+ __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_r = __pyx_t_3;
+ __pyx_t_3 = 0;
goto __pyx_L0;
goto __pyx_L5;
}
__pyx_L5:;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":86
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":87
* return False
*
* c = wkhtmltopdf_create_converter(self._c_global_settings) # <<<<<<<<<<<<<<
*
- * for page in self.pages:
+ * for page in pages:
*/
- __pyx_v_c = wkhtmltopdf_create_converter(((struct __pyx_obj_9wkhtmltox_Pdf *)__pyx_v_self)->_c_global_settings);
+ __pyx_v_c = wkhtmltopdf_create_converter(((struct __pyx_obj_9wkhtmltox__Pdf *)__pyx_v_self)->_c_global_settings);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":88
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":89
* c = wkhtmltopdf_create_converter(self._c_global_settings)
*
- * for page in self.pages: # <<<<<<<<<<<<<<
+ * for page in pages: # <<<<<<<<<<<<<<
* os = wkhtmltopdf_create_object_settings()
* for k, v in page.iteritems():
*/
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pages); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
- __pyx_t_2 = 0; __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4);
+ if (PyList_CheckExact(__pyx_v_pages) || PyTuple_CheckExact(__pyx_v_pages)) {
+ __pyx_t_1 = 0; __pyx_t_3 = __pyx_v_pages; __Pyx_INCREF(__pyx_t_3);
} else {
- __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_pages); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
for (;;) {
- if (likely(PyList_CheckExact(__pyx_t_4))) {
- if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
- __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
- } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
- if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
+ if (likely(PyList_CheckExact(__pyx_t_3))) {
+ if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
+ __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++;
+ } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
+ if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
+ __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++;
} else {
- __pyx_t_1 = PyIter_Next(__pyx_t_4);
- if (!__pyx_t_1) {
- if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyIter_Next(__pyx_t_3);
+ if (!__pyx_t_4) {
+ if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
break;
}
- __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_GOTREF(__pyx_t_4);
}
__Pyx_DECREF(__pyx_v_page);
- __pyx_v_page = __pyx_t_1;
- __pyx_t_1 = 0;
+ __pyx_v_page = __pyx_t_4;
+ __pyx_t_4 = 0;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":89
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":90
*
- * for page in self.pages:
+ * for page in pages:
* os = wkhtmltopdf_create_object_settings() # <<<<<<<<<<<<<<
* for k, v in page.iteritems():
* wkhtmltopdf_set_object_setting(os, k, v)
*/
__pyx_v_os = wkhtmltopdf_create_object_settings();
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":90
- * for page in self.pages:
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":91
+ * for page in pages:
* os = wkhtmltopdf_create_object_settings()
* for k, v in page.iteritems(): # <<<<<<<<<<<<<<
* wkhtmltopdf_set_object_setting(os, k, v)
* wkhtmltopdf_add_object(c, os, NULL)
*/
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_page, __pyx_n_s__iteritems); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_GetAttr(__pyx_v_page, __pyx_n_s__iteritems); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
- __pyx_t_5 = 0; __pyx_t_1 = __pyx_t_6; __Pyx_INCREF(__pyx_t_1);
+ __pyx_t_5 = 0; __pyx_t_4 = __pyx_t_6; __Pyx_INCREF(__pyx_t_4);
} else {
- __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
for (;;) {
- if (likely(PyList_CheckExact(__pyx_t_1))) {
- if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
- __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
- } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
- if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
- __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
+ if (likely(PyList_CheckExact(__pyx_t_4))) {
+ if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
+ __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
+ } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
+ if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
+ __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
} else {
- __pyx_t_6 = PyIter_Next(__pyx_t_1);
+ __pyx_t_6 = PyIter_Next(__pyx_t_4);
if (!__pyx_t_6) {
- if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
break;
}
__Pyx_GOTREF(__pyx_t_6);
@@ -847,14 +817,14 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON
__pyx_v_v = __pyx_t_8;
__pyx_t_8 = 0;
} else {
- __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_9, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_9, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_9, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_9, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
- if (__Pyx_EndUnpack(__pyx_t_9, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_EndUnpack(__pyx_t_9, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_v_k);
__pyx_v_k = __pyx_t_7;
@@ -864,20 +834,20 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON
__pyx_t_8 = 0;
}
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":91
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":92
* os = wkhtmltopdf_create_object_settings()
* for k, v in page.iteritems():
* wkhtmltopdf_set_object_setting(os, k, v) # <<<<<<<<<<<<<<
* wkhtmltopdf_add_object(c, os, NULL)
*
*/
- __pyx_t_10 = PyBytes_AsString(__pyx_v_k); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_11 = PyBytes_AsString(__pyx_v_v); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_10 = PyBytes_AsString(__pyx_v_k); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_11 = PyBytes_AsString(__pyx_v_v); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
wkhtmltopdf_set_object_setting(__pyx_v_os, __pyx_t_10, __pyx_t_11);
}
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":92
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":93
* for k, v in page.iteritems():
* wkhtmltopdf_set_object_setting(os, k, v)
* wkhtmltopdf_add_object(c, os, NULL) # <<<<<<<<<<<<<<
@@ -886,9 +856,9 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON
*/
wkhtmltopdf_add_object(__pyx_v_c, __pyx_v_os, NULL);
}
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":94
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":95
* wkhtmltopdf_add_object(c, os, NULL)
*
* ret = wkhtmltopdf_convert(c) # <<<<<<<<<<<<<<
@@ -897,16 +867,16 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON
*/
__pyx_v_ret = wkhtmltopdf_convert(__pyx_v_c);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":95
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":96
*
* ret = wkhtmltopdf_convert(c)
* self.last_http_error_code = wkhtmltopdf_http_error_code(c) # <<<<<<<<<<<<<<
* wkhtmltopdf_destroy_converter(c)
* return ret
*/
- ((struct __pyx_obj_9wkhtmltox_Pdf *)__pyx_v_self)->last_http_error_code = wkhtmltopdf_http_error_code(__pyx_v_c);
+ ((struct __pyx_obj_9wkhtmltox__Pdf *)__pyx_v_self)->last_http_error_code = wkhtmltopdf_http_error_code(__pyx_v_c);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":96
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":97
* ret = wkhtmltopdf_convert(c)
* self.last_http_error_code = wkhtmltopdf_http_error_code(c)
* wkhtmltopdf_destroy_converter(c) # <<<<<<<<<<<<<<
@@ -915,30 +885,30 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON
*/
wkhtmltopdf_destroy_converter(__pyx_v_c);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":97
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":98
* self.last_http_error_code = wkhtmltopdf_http_error_code(c)
* wkhtmltopdf_destroy_converter(c)
* return ret # <<<<<<<<<<<<<<
*
* def http_error_code(self):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_ret); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
+ __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_ret); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_r = __pyx_t_3;
+ __pyx_t_3 = 0;
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("wkhtmltox.Pdf.convert");
+ __Pyx_AddTraceback("wkhtmltox._Pdf.convert");
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(__pyx_v_page);
@@ -949,29 +919,29 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_v_self, CYTHON
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":99
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":100
* return ret
*
* def http_error_code(self): # <<<<<<<<<<<<<<
* return self.last_http_error_code
*
*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_http_error_code(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pf_9wkhtmltox_3Pdf_http_error_code(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9wkhtmltox_4_Pdf_http_error_code(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pf_9wkhtmltox_4_Pdf_http_error_code(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = NULL;
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("http_error_code");
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":100
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":101
*
* def http_error_code(self):
* return self.last_http_error_code # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_obj_9wkhtmltox_Pdf *)__pyx_v_self)->last_http_error_code); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_obj_9wkhtmltox__Pdf *)__pyx_v_self)->last_http_error_code); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -981,42 +951,342 @@ static PyObject *__pyx_pf_9wkhtmltox_3Pdf_http_error_code(PyObject *__pyx_v_self
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("wkhtmltox.Pdf.http_error_code");
+ __Pyx_AddTraceback("wkhtmltox._Pdf.http_error_code");
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":107
+ * pages = []
+ *
+ * def __init__(self): # <<<<<<<<<<<<<<
+ * self._pdf = _Pdf()
+ * self.pages = []
+ */
+
+static PyObject *__pyx_pf_9wkhtmltox_3Pdf___init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static PyMethodDef __pyx_mdef_9wkhtmltox_3Pdf___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf___init__, METH_O, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_9wkhtmltox_3Pdf___init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ PyObject *__pyx_t_1 = NULL;
+ __Pyx_RefNannySetupContext("__init__");
+ __pyx_self = __pyx_self;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":108
+ *
+ * def __init__(self):
+ * self._pdf = _Pdf() # <<<<<<<<<<<<<<
+ * self.pages = []
+ *
+ */
+ __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9wkhtmltox__Pdf)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s___pdf, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":109
+ * def __init__(self):
+ * self._pdf = _Pdf()
+ * self.pages = [] # <<<<<<<<<<<<<<
+ *
+ * def add_page(self, settings):
+ */
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+ if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__pages, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("wkhtmltox.Pdf.__init__");
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":111
+ * self.pages = []
+ *
+ * def add_page(self, settings): # <<<<<<<<<<<<<<
+ * self.pages.append(settings)
+ *
+ */
+
+static PyObject *__pyx_pf_9wkhtmltox_3Pdf_add_page(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_9wkhtmltox_3Pdf_add_page = {__Pyx_NAMESTR("add_page"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf_add_page, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_9wkhtmltox_3Pdf_add_page(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_self = 0;
+ PyObject *__pyx_v_settings = 0;
+ PyObject *__pyx_r = NULL;
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__settings,0};
+ __Pyx_RefNannySetupContext("add_page");
+ __pyx_self = __pyx_self;
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+ PyObject* values[2] = {0,0};
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 0:
+ values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+ if (likely(values[0])) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ case 1:
+ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__settings);
+ if (likely(values[1])) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("add_page", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add_page") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ __pyx_v_self = values[0];
+ __pyx_v_settings = values[1];
+ } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+ goto __pyx_L5_argtuple_error;
+ } else {
+ __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+ __pyx_v_settings = PyTuple_GET_ITEM(__pyx_args, 1);
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L5_argtuple_error:;
+ __Pyx_RaiseArgtupleInvalid("add_page", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("wkhtmltox.Pdf.add_page");
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":112
+ *
+ * def add_page(self, settings):
+ * self.pages.append(settings) # <<<<<<<<<<<<<<
+ *
+ * def convert(self):
+ */
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pages); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_settings); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_AddTraceback("wkhtmltox.Pdf.add_page");
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":114
+ * self.pages.append(settings)
+ *
+ * def convert(self): # <<<<<<<<<<<<<<
+ * self._pdf.convert(self.pages)
+ *
+ */
+
+static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static PyMethodDef __pyx_mdef_9wkhtmltox_3Pdf_convert = {__Pyx_NAMESTR("convert"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf_convert, METH_O, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_9wkhtmltox_3Pdf_convert(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ __Pyx_RefNannySetupContext("convert");
+ __pyx_self = __pyx_self;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":115
+ *
+ * def convert(self):
+ * self._pdf.convert(self.pages) # <<<<<<<<<<<<<<
+ *
+ * def __getattr__(self, name):
+ */
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___pdf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__convert); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pages); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_AddTraceback("wkhtmltox.Pdf.convert");
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":117
+ * self._pdf.convert(self.pages)
+ *
+ * def __getattr__(self, name): # <<<<<<<<<<<<<<
+ * return getattr(self._pdf, name)
+ *
+ */
+
+static PyObject *__pyx_pf_9wkhtmltox_3Pdf___getattr__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_9wkhtmltox_3Pdf___getattr__ = {__Pyx_NAMESTR("__getattr__"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf___getattr__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
+static PyObject *__pyx_pf_9wkhtmltox_3Pdf___getattr__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_self = 0;
+ PyObject *__pyx_v_name = 0;
+ PyObject *__pyx_r = NULL;
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__name,0};
+ __Pyx_RefNannySetupContext("__getattr__");
+ __pyx_self = __pyx_self;
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+ PyObject* values[2] = {0,0};
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 0:
+ values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
+ if (likely(values[0])) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ case 1:
+ values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name);
+ if (likely(values[1])) kw_args--;
+ else {
+ __Pyx_RaiseArgtupleInvalid("__getattr__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__getattr__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ __pyx_v_self = values[0];
+ __pyx_v_name = values[1];
+ } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+ goto __pyx_L5_argtuple_error;
+ } else {
+ __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
+ __pyx_v_name = PyTuple_GET_ITEM(__pyx_args, 1);
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L5_argtuple_error:;
+ __Pyx_RaiseArgtupleInvalid("__getattr__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("wkhtmltox.Pdf.__getattr__");
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":118
+ *
+ * def __getattr__(self, name):
+ * return getattr(self._pdf, name) # <<<<<<<<<<<<<<
+ *
+ *
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___pdf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_v_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_r = __pyx_t_2;
+ __pyx_t_2 = 0;
+ goto __pyx_L0;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_AddTraceback("wkhtmltox.Pdf.__getattr__");
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":107
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":125
* cdef bint last_http_error_code
*
* def __cinit__(self): # <<<<<<<<<<<<<<
- * wkhtmltoimage_init(0)
- * self._c_global_settings = wkhtmltoimage_create_global_settings()
+ * global wkhtmltoimage_is_init
+ * if not wkhtmltoimage_is_init:
*/
static int __pyx_pf_9wkhtmltox_5Image___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_9wkhtmltox_5Image___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
int __pyx_r;
+ int __pyx_t_1;
__Pyx_RefNannySetupContext("__cinit__");
if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
__Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":108
- *
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":127
* def __cinit__(self):
- * wkhtmltoimage_init(0) # <<<<<<<<<<<<<<
- * self._c_global_settings = wkhtmltoimage_create_global_settings()
+ * global wkhtmltoimage_is_init
+ * if not wkhtmltoimage_is_init: # <<<<<<<<<<<<<<
+ * wkhtmltoimage_is_init = wkhtmltoimage_init(0)
*
*/
- wkhtmltoimage_init(0);
+ __pyx_t_1 = (!__pyx_v_9wkhtmltox_wkhtmltoimage_is_init);
+ if (__pyx_t_1) {
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":109
- * def __cinit__(self):
- * wkhtmltoimage_init(0)
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":128
+ * global wkhtmltoimage_is_init
+ * if not wkhtmltoimage_is_init:
+ * wkhtmltoimage_is_init = wkhtmltoimage_init(0) # <<<<<<<<<<<<<<
+ *
+ * self._c_global_settings = wkhtmltoimage_create_global_settings()
+ */
+ __pyx_v_9wkhtmltox_wkhtmltoimage_is_init = wkhtmltoimage_init(0);
+ goto __pyx_L5;
+ }
+ __pyx_L5:;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":130
+ * wkhtmltoimage_is_init = wkhtmltoimage_init(0)
+ *
* self._c_global_settings = wkhtmltoimage_create_global_settings() # <<<<<<<<<<<<<<
*
* def __dealloc__(self):
@@ -1028,32 +1298,23 @@ static int __pyx_pf_9wkhtmltox_5Image___cinit__(PyObject *__pyx_v_self, PyObject
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":111
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":132
* self._c_global_settings = wkhtmltoimage_create_global_settings()
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
- * wkhtmltoimage_deinit();
- *
+ * pass
+ * #wkhtmltoimage_deinit();
*/
static void __pyx_pf_9wkhtmltox_5Image___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_9wkhtmltox_5Image___dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannySetupContext("__dealloc__");
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":112
- *
- * def __dealloc__(self):
- * wkhtmltoimage_deinit(); # <<<<<<<<<<<<<<
- *
- * def version(self):
- */
- wkhtmltoimage_deinit();
-
__Pyx_RefNannyFinishContext();
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":114
- * wkhtmltoimage_deinit();
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":136
+ * #wkhtmltoimage_deinit();
*
* def version(self): # <<<<<<<<<<<<<<
* return wkhtmltopdf_version();
@@ -1066,15 +1327,15 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_version(PyObject *__pyx_v_self, CYTH
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("version");
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":115
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":137
*
* def version(self):
* return wkhtmltopdf_version(); # <<<<<<<<<<<<<<
*
* def set_global_setting(self, char *name, char *value):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyBytes_FromString(wkhtmltopdf_version()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(wkhtmltopdf_version()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
@@ -1092,7 +1353,7 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_version(PyObject *__pyx_v_self, CYTH
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":117
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":139
* return wkhtmltopdf_version();
*
* def set_global_setting(self, char *name, char *value): # <<<<<<<<<<<<<<
@@ -1126,38 +1387,38 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_set_global_setting(PyObject *__pyx_v
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value);
if (likely(values[1])) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("set_global_setting", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("set_global_setting", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_global_setting") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "set_global_setting") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
- __pyx_v_name = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- __pyx_v_value = PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_name = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_value = PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
- __pyx_v_name = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- __pyx_v_value = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_name = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_value = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_value) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("set_global_setting", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("set_global_setting", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("wkhtmltox.Image.set_global_setting");
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":118
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":140
*
* def set_global_setting(self, char *name, char *value):
* return wkhtmltoimage_set_global_setting(self._c_global_settings, name, value) # <<<<<<<<<<<<<<
*
* def convert(self):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(wkhtmltoimage_set_global_setting(((struct __pyx_obj_9wkhtmltox_Image *)__pyx_v_self)->_c_global_settings, __pyx_v_name, __pyx_v_value)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyBool_FromLong(wkhtmltoimage_set_global_setting(((struct __pyx_obj_9wkhtmltox_Image *)__pyx_v_self)->_c_global_settings, __pyx_v_name, __pyx_v_value)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -1175,7 +1436,7 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_set_global_setting(PyObject *__pyx_v
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":120
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":142
* return wkhtmltoimage_set_global_setting(self._c_global_settings, name, value)
*
* def convert(self): # <<<<<<<<<<<<<<
@@ -1191,7 +1452,7 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_convert(PyObject *__pyx_v_self, CYTH
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("convert");
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":122
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":144
* def convert(self):
* cdef wkhtmltoimage_converter *c
* c = wkhtmltoimage_create_converter(self._c_global_settings, NULL) # <<<<<<<<<<<<<<
@@ -1200,7 +1461,7 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_convert(PyObject *__pyx_v_self, CYTH
*/
__pyx_v_c = wkhtmltoimage_create_converter(((struct __pyx_obj_9wkhtmltox_Image *)__pyx_v_self)->_c_global_settings, NULL);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":123
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":145
* cdef wkhtmltoimage_converter *c
* c = wkhtmltoimage_create_converter(self._c_global_settings, NULL)
* ret = wkhtmltoimage_convert(c) # <<<<<<<<<<<<<<
@@ -1209,7 +1470,7 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_convert(PyObject *__pyx_v_self, CYTH
*/
__pyx_v_ret = wkhtmltoimage_convert(__pyx_v_c);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":124
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":146
* c = wkhtmltoimage_create_converter(self._c_global_settings, NULL)
* ret = wkhtmltoimage_convert(c)
* self.last_http_error_code = wkhtmltoimage_http_error_code(c) # <<<<<<<<<<<<<<
@@ -1218,7 +1479,7 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_convert(PyObject *__pyx_v_self, CYTH
*/
((struct __pyx_obj_9wkhtmltox_Image *)__pyx_v_self)->last_http_error_code = wkhtmltoimage_http_error_code(__pyx_v_c);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":125
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":147
* ret = wkhtmltoimage_convert(c)
* self.last_http_error_code = wkhtmltoimage_http_error_code(c)
* wkhtmltoimage_destroy_converter(c) # <<<<<<<<<<<<<<
@@ -1227,15 +1488,15 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_convert(PyObject *__pyx_v_self, CYTH
*/
wkhtmltoimage_destroy_converter(__pyx_v_c);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":126
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":148
* self.last_http_error_code = wkhtmltoimage_http_error_code(c)
* wkhtmltoimage_destroy_converter(c)
* return ret # <<<<<<<<<<<<<<
*
* def http_error_code(self):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_ret); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_ret); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -1253,7 +1514,7 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_convert(PyObject *__pyx_v_self, CYTH
return __pyx_r;
}
-/* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":128
+/* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":150
* return ret
*
* def http_error_code(self): # <<<<<<<<<<<<<<
@@ -1266,13 +1527,13 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_http_error_code(PyObject *__pyx_v_se
PyObject *__pyx_t_1 = NULL;
__Pyx_RefNannySetupContext("http_error_code");
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":129
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":151
*
* def http_error_code(self):
* return self.last_http_error_code # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_obj_9wkhtmltox_Image *)__pyx_v_self)->last_http_error_code); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_obj_9wkhtmltox_Image *)__pyx_v_self)->last_http_error_code); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -1290,38 +1551,37 @@ static PyObject *__pyx_pf_9wkhtmltox_5Image_http_error_code(PyObject *__pyx_v_se
return __pyx_r;
}
-static PyObject *__pyx_tp_new_9wkhtmltox_Pdf(PyTypeObject *t, PyObject *a, PyObject *k) {
+static PyObject *__pyx_tp_new_9wkhtmltox__Pdf(PyTypeObject *t, PyObject *a, PyObject *k) {
PyObject *o = (*t->tp_alloc)(t, 0);
if (!o) return 0;
- if (__pyx_pf_9wkhtmltox_3Pdf___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
+ if (__pyx_pf_9wkhtmltox_4_Pdf___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
Py_DECREF(o); o = 0;
}
return o;
}
-static void __pyx_tp_dealloc_9wkhtmltox_Pdf(PyObject *o) {
+static void __pyx_tp_dealloc_9wkhtmltox__Pdf(PyObject *o) {
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
- __pyx_pf_9wkhtmltox_3Pdf___dealloc__(o);
+ __pyx_pf_9wkhtmltox_4_Pdf___dealloc__(o);
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
(*Py_TYPE(o)->tp_free)(o);
}
-static PyMethodDef __pyx_methods_9wkhtmltox_Pdf[] = {
- {__Pyx_NAMESTR("version"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf_version, METH_NOARGS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("set_global_setting"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf_set_global_setting, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("add_page"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf_add_page, METH_O, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("convert"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf_convert, METH_NOARGS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("http_error_code"), (PyCFunction)__pyx_pf_9wkhtmltox_3Pdf_http_error_code, METH_NOARGS, __Pyx_DOCSTR(0)},
+static PyMethodDef __pyx_methods_9wkhtmltox__Pdf[] = {
+ {__Pyx_NAMESTR("version"), (PyCFunction)__pyx_pf_9wkhtmltox_4_Pdf_version, METH_NOARGS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("set_global_setting"), (PyCFunction)__pyx_pf_9wkhtmltox_4_Pdf_set_global_setting, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("convert"), (PyCFunction)__pyx_pf_9wkhtmltox_4_Pdf_convert, METH_O, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("http_error_code"), (PyCFunction)__pyx_pf_9wkhtmltox_4_Pdf_http_error_code, METH_NOARGS, __Pyx_DOCSTR(0)},
{0, 0, 0, 0}
};
-static PyNumberMethods __pyx_tp_as_number_Pdf = {
+static PyNumberMethods __pyx_tp_as_number__Pdf = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
@@ -1379,7 +1639,7 @@ static PyNumberMethods __pyx_tp_as_number_Pdf = {
#endif
};
-static PySequenceMethods __pyx_tp_as_sequence_Pdf = {
+static PySequenceMethods __pyx_tp_as_sequence__Pdf = {
0, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
@@ -1392,13 +1652,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Pdf = {
0, /*sq_inplace_repeat*/
};
-static PyMappingMethods __pyx_tp_as_mapping_Pdf = {
+static PyMappingMethods __pyx_tp_as_mapping__Pdf = {
0, /*mp_length*/
0, /*mp_subscript*/
0, /*mp_ass_subscript*/
};
-static PyBufferProcs __pyx_tp_as_buffer_Pdf = {
+static PyBufferProcs __pyx_tp_as_buffer__Pdf = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
@@ -1419,12 +1679,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Pdf = {
#endif
};
-PyTypeObject __pyx_type_9wkhtmltox_Pdf = {
+PyTypeObject __pyx_type_9wkhtmltox__Pdf = {
PyVarObject_HEAD_INIT(0, 0)
- __Pyx_NAMESTR("wkhtmltox.Pdf"), /*tp_name*/
- sizeof(struct __pyx_obj_9wkhtmltox_Pdf), /*tp_basicsize*/
+ __Pyx_NAMESTR("wkhtmltox._Pdf"), /*tp_name*/
+ sizeof(struct __pyx_obj_9wkhtmltox__Pdf), /*tp_basicsize*/
0, /*tp_itemsize*/
- __pyx_tp_dealloc_9wkhtmltox_Pdf, /*tp_dealloc*/
+ __pyx_tp_dealloc_9wkhtmltox__Pdf, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -1434,15 +1694,15 @@ PyTypeObject __pyx_type_9wkhtmltox_Pdf = {
0, /*reserved*/
#endif
0, /*tp_repr*/
- &__pyx_tp_as_number_Pdf, /*tp_as_number*/
- &__pyx_tp_as_sequence_Pdf, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_Pdf, /*tp_as_mapping*/
+ &__pyx_tp_as_number__Pdf, /*tp_as_number*/
+ &__pyx_tp_as_sequence__Pdf, /*tp_as_sequence*/
+ &__pyx_tp_as_mapping__Pdf, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
- &__pyx_tp_as_buffer_Pdf, /*tp_as_buffer*/
+ &__pyx_tp_as_buffer__Pdf, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
@@ -1451,7 +1711,7 @@ PyTypeObject __pyx_type_9wkhtmltox_Pdf = {
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
- __pyx_methods_9wkhtmltox_Pdf, /*tp_methods*/
+ __pyx_methods_9wkhtmltox__Pdf, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
@@ -1461,7 +1721,7 @@ PyTypeObject __pyx_type_9wkhtmltox_Pdf = {
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
- __pyx_tp_new_9wkhtmltox_Pdf, /*tp_new*/
+ __pyx_tp_new_9wkhtmltox__Pdf, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
@@ -1679,18 +1939,28 @@ static struct PyModuleDef __pyx_moduledef = {
static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 1},
+ {&__pyx_n_s__Pdf, __pyx_k__Pdf, sizeof(__pyx_k__Pdf), 0, 0, 1, 1},
+ {&__pyx_n_s____getattr__, __pyx_k____getattr__, sizeof(__pyx_k____getattr__), 0, 0, 1, 1},
+ {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
{&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
{&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
{&__pyx_n_s___c_global_settings, __pyx_k___c_global_settings, sizeof(__pyx_k___c_global_settings), 0, 0, 1, 1},
- {&__pyx_n_s___c_object_settings, __pyx_k___c_object_settings, sizeof(__pyx_k___c_object_settings), 0, 0, 1, 1},
+ {&__pyx_n_s___pdf, __pyx_k___pdf, sizeof(__pyx_k___pdf), 0, 0, 1, 1},
+ {&__pyx_n_s__add_page, __pyx_k__add_page, sizeof(__pyx_k__add_page), 0, 0, 1, 1},
+ {&__pyx_n_s__convert, __pyx_k__convert, sizeof(__pyx_k__convert), 0, 0, 1, 1},
+ {&__pyx_n_s__getattr, __pyx_k__getattr, sizeof(__pyx_k__getattr), 0, 0, 1, 1},
{&__pyx_n_s__iteritems, __pyx_k__iteritems, sizeof(__pyx_k__iteritems), 0, 0, 1, 1},
{&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
{&__pyx_n_s__pages, __pyx_k__pages, sizeof(__pyx_k__pages), 0, 0, 1, 1},
+ {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
+ {&__pyx_n_s__settings, __pyx_k__settings, sizeof(__pyx_k__settings), 0, 0, 1, 1},
{&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1},
{0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
+ __pyx_builtin_getattr = __Pyx_GetName(__pyx_b, __pyx_n_s__getattr); if (!__pyx_builtin_getattr) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
+ __pyx_L1_error:;
return -1;
}
@@ -1710,6 +1980,9 @@ PyMODINIT_FUNC PyInit_wkhtmltox(void)
#endif
{
PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
#if CYTHON_REFNANNY
void* __pyx_refnanny = NULL;
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
@@ -1756,30 +2029,122 @@ PyMODINIT_FUNC PyInit_wkhtmltox(void)
/*--- Global init code ---*/
/*--- Function export code ---*/
/*--- Type init code ---*/
- if (PyType_Ready(&__pyx_type_9wkhtmltox_Pdf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "Pdf", (PyObject *)&__pyx_type_9wkhtmltox_Pdf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_ptype_9wkhtmltox_Pdf = &__pyx_type_9wkhtmltox_Pdf;
- if (PyType_Ready(&__pyx_type_9wkhtmltox_Image) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "Image", (PyObject *)&__pyx_type_9wkhtmltox_Image) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_9wkhtmltox__Pdf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "_Pdf", (PyObject *)&__pyx_type_9wkhtmltox__Pdf) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_ptype_9wkhtmltox__Pdf = &__pyx_type_9wkhtmltox__Pdf;
+ if (PyType_Ready(&__pyx_type_9wkhtmltox_Image) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "Image", (PyObject *)&__pyx_type_9wkhtmltox_Image) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_9wkhtmltox_Image = &__pyx_type_9wkhtmltox_Image;
/*--- Type import code ---*/
/*--- Function import code ---*/
/*--- Execution code ---*/
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":60
- * cdef wkhtmltopdf_object_settings *_c_object_settings
- * cdef bint last_http_error_code
- * pages = [] # <<<<<<<<<<<<<<
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":56
+ *
+ *
+ * cdef int wkhtmltopdf_is_init = 0 # <<<<<<<<<<<<<<
+ * cdef int wkhtmltoimage_is_init = 0
*
- * def __cinit__(self):
*/
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_v_9wkhtmltox_wkhtmltopdf_is_init = 0;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":57
+ *
+ * cdef int wkhtmltopdf_is_init = 0
+ * cdef int wkhtmltoimage_is_init = 0 # <<<<<<<<<<<<<<
+ *
+ * cdef class _Pdf:
+ */
+ __pyx_v_9wkhtmltox_wkhtmltoimage_is_init = 0;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":104
+ *
+ *
+ * class Pdf: # <<<<<<<<<<<<<<
+ * pages = []
+ *
+ */
+ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
- if (PyDict_SetItem((PyObject *)__pyx_ptype_9wkhtmltox_Pdf->tp_dict, __pyx_n_s__pages, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__Pdf, "wkhtmltox"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":105
+ *
+ * class Pdf:
+ * pages = [] # <<<<<<<<<<<<<<
+ *
+ * def __init__(self):
+ */
+ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__pages, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":107
+ * pages = []
+ *
+ * def __init__(self): # <<<<<<<<<<<<<<
+ * self._pdf = _Pdf()
+ * self.pages = []
+ */
+ __pyx_t_3 = PyCFunction_New(&__pyx_mdef_9wkhtmltox_3Pdf___init__, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":111
+ * self.pages = []
+ *
+ * def add_page(self, settings): # <<<<<<<<<<<<<<
+ * self.pages.append(settings)
+ *
+ */
+ __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9wkhtmltox_3Pdf_add_page, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__add_page, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":114
+ * self.pages.append(settings)
+ *
+ * def convert(self): # <<<<<<<<<<<<<<
+ * self._pdf.convert(self.pages)
+ *
+ */
+ __pyx_t_3 = PyCFunction_New(&__pyx_mdef_9wkhtmltox_3Pdf_convert, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = PyMethod_New(__pyx_t_3, 0, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s__convert, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":117
+ * self._pdf.convert(self.pages)
+ *
+ * def __getattr__(self, name): # <<<<<<<<<<<<<<
+ * return getattr(self._pdf, name)
+ *
+ */
+ __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9wkhtmltox_3Pdf___getattr__, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ __pyx_t_3 = PyMethod_New(__pyx_t_4, 0, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ if (PyObject_SetAttr(__pyx_t_2, __pyx_n_s____getattr__, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Pdf, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
- PyType_Modified(__pyx_ptype_9wkhtmltox_Pdf);
- /* "/Users/mreiferson/dev/vrc/git/py-wkhtmltox/wkhtmltox.pyx":1
+ /* "/Users/mreiferson/dev/git/py-wkhtmltox/wkhtmltox.pyx":1
* cdef extern from "wkhtmltox/pdf.h": # <<<<<<<<<<<<<<
* struct wkhtmltopdf_converter:
* pass
@@ -1791,6 +2156,9 @@ PyMODINIT_FUNC PyInit_wkhtmltox(void)
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
if (__pyx_m) {
__Pyx_AddTraceback("init wkhtmltox");
Py_DECREF(__pyx_m); __pyx_m = 0;
@@ -1808,6 +2176,14 @@ PyMODINIT_FUNC PyInit_wkhtmltox(void)
/* Runtime support code */
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
+ PyObject *result;
+ result = PyObject_GetAttr(dict, name);
+ if (!result)
+ PyErr_SetObject(PyExc_NameError, name);
+ return result;
+}
+
static void __Pyx_RaiseArgtupleInvalid(
const char* func_name,
int exact,
@@ -2006,6 +2382,31 @@ static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
return -1;
}
+static PyObject *__Pyx_CreateClass(
+ PyObject *bases, PyObject *dict, PyObject *name, const char *modname)
+{
+ PyObject *py_modname;
+ PyObject *result = 0;
+
+ #if PY_MAJOR_VERSION < 3
+ py_modname = PyString_FromString(modname);
+ #else
+ py_modname = PyUnicode_FromString(modname);
+ #endif
+ if (!py_modname)
+ goto bad;
+ if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
+ goto bad;
+ #if PY_MAJOR_VERSION < 3
+ result = PyClass_New(bases, dict, name);
+ #else
+ result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL);
+ #endif
+bad:
+ Py_XDECREF(py_modname);
+ return result;
+}
+
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero;
View
50 wkhtmltox.pyx
@@ -53,39 +53,40 @@ cdef extern from "wkhtmltox/image.h":
int wkhtmltoimage_http_error_code(wkhtmltoimage_converter *converter)
-cdef class Pdf:
+cdef int wkhtmltopdf_is_init = 0
+cdef int wkhtmltoimage_is_init = 0
+
+cdef class _Pdf:
cdef wkhtmltopdf_global_settings *_c_global_settings
- cdef wkhtmltopdf_object_settings *_c_object_settings
cdef bint last_http_error_code
- pages = []
def __cinit__(self):
- wkhtmltopdf_init(0)
+ global wkhtmltopdf_is_init
+ if not wkhtmltopdf_is_init:
+ wkhtmltopdf_is_init = wkhtmltopdf_init(0)
+
self._c_global_settings = wkhtmltopdf_create_global_settings()
- self._c_object_settings = wkhtmltopdf_create_object_settings()
def __dealloc__(self):
- wkhtmltopdf_deinit();
+ pass
+ #wkhtmltopdf_deinit();
def version(self):
return wkhtmltopdf_version();
def set_global_setting(self, char *name, char *value):
return wkhtmltopdf_set_global_setting(self._c_global_settings, name, value)
- def add_page(self, settings):
- self.pages.append(settings)
-
- def convert(self):
+ def convert(self, pages):
cdef wkhtmltopdf_converter *c
cdef wkhtmltopdf_object_settings *os
- if not len(self.pages):
+ if not len(pages):
return False
c = wkhtmltopdf_create_converter(self._c_global_settings)
- for page in self.pages:
+ for page in pages:
os = wkhtmltopdf_create_object_settings()
for k, v in page.iteritems():
wkhtmltopdf_set_object_setting(os, k, v)
@@ -100,16 +101,37 @@ cdef class Pdf:
return self.last_http_error_code
+class Pdf:
+ pages = []
+
+ def __init__(self):
+ self._pdf = _Pdf()
+ self.pages = []
+
+ def add_page(self, settings):
+ self.pages.append(settings)
+
+ def convert(self):
+ self._pdf.convert(self.pages)
+
+ def __getattr__(self, name):
+ return getattr(self._pdf, name)
+
+
cdef class Image:
cdef wkhtmltoimage_global_settings *_c_global_settings
cdef bint last_http_error_code
def __cinit__(self):
- wkhtmltoimage_init(0)
+ global wkhtmltoimage_is_init
+ if not wkhtmltoimage_is_init:
+ wkhtmltoimage_is_init = wkhtmltoimage_init(0)
+
self._c_global_settings = wkhtmltoimage_create_global_settings()
def __dealloc__(self):
- wkhtmltoimage_deinit();
+ pass
+ #wkhtmltoimage_deinit();
def version(self):
return wkhtmltopdf_version();

0 comments on commit 852fd9d

Please sign in to comment.
Something went wrong with that request. Please try again.