summaryrefslogtreecommitdiff
path: root/swig/python/python.i
blob: 139cc2d698ab4ae00004cb2f383d5143642a577b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55


%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;
  }
}