summaryrefslogtreecommitdiff
path: root/swig/python/python.i
diff options
context:
space:
mode:
Diffstat (limited to 'swig/python/python.i')
-rw-r--r--swig/python/python.i55
1 files changed, 55 insertions, 0 deletions
diff --git a/swig/python/python.i b/swig/python/python.i
new file mode 100644
index 0000000..139cc2d
--- /dev/null
+++ b/swig/python/python.i
@@ -0,0 +1,55 @@
+
+
+%rename *::asString "__str__";
+
+%ignore zypp::Arch_empty;
+
+namespace zypp
+{
+ // These operators must be ignored otherwise the wrapper does
+ // not compile (using swig 1.3.29).
+ %ignore operator==;
+ %ignore operator!=;
+
+ // Just to avoid warnings.
+ %ignore operator<<;
+ namespace repo
+ {
+ // These operators must be ignored otherwise the wrapper does
+ // not compile (using swig 1.3.29).
+ %ignore operator==;
+ %ignore operator!=;
+
+ // Just to avoid warnings.
+ %ignore operator<<;
+ }
+
+}
+
+
+
+%define iter( cls )
+%extend cls {
+ %pythoncode %{
+ def __iter__(self):
+ r = self.range()
+ while not r.empty():
+ yield r.head()
+ r.removeFirst()
+ %}
+};
+%enddef
+
+
+%exception
+{
+ try {
+ $action
+ }
+ catch (const Exception& e) {
+ std::string tmp = e.historyAsString() + e.asUserString();
+ PyErr_SetString(PyExc_RuntimeError, const_cast<char*>(tmp.c_str()));
+ return NULL;
+ }
+}
+