From f36b121327827cf93f4efb0a75948e8c3afc7d9f Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Thu, 11 Dec 2014 18:08:51 +0100 Subject: [PATCH] - removed python bindings (not packaged for two years) --- bindings/Makefile.am | 5 - bindings/README | 5 - bindings/python/.gitignore | 3 - bindings/python/Makefile.am | 39 ----- bindings/python/examples/create.py | 11 -- bindings/python/examples/test.py | 104 ------------ bindings/python/libsnapper.i | 251 ----------------------------- 7 files changed, 418 deletions(-) delete mode 100644 bindings/Makefile.am delete mode 100644 bindings/README delete mode 100644 bindings/python/.gitignore delete mode 100644 bindings/python/Makefile.am delete mode 100755 bindings/python/examples/create.py delete mode 100755 bindings/python/examples/test.py delete mode 100644 bindings/python/libsnapper.i diff --git a/bindings/Makefile.am b/bindings/Makefile.am deleted file mode 100644 index 25b67293..00000000 --- a/bindings/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -# -# Makefile.am for libsnapper/bindings -# - -SUBDIRS = python diff --git a/bindings/README b/bindings/README deleted file mode 100644 index 3f9add6e..00000000 --- a/bindings/README +++ /dev/null @@ -1,5 +0,0 @@ - -The language bindings here should not be used anymore. The now preferred -method to use snapper is via DBus. You can find examples for various languages -in the examples directory. - diff --git a/bindings/python/.gitignore b/bindings/python/.gitignore deleted file mode 100644 index 67a51328..00000000 --- a/bindings/python/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -libsnapper.py -libsnapper_wrap.* -_libsnapper* diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am deleted file mode 100644 index 22ef8eca..00000000 --- a/bindings/python/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# -# Makefile.am for libsnapper/bindings/python -# - -EXTRA_DIST = libsnapper.i - -AM_CXXFLAGS = -fPIC -DPIC - -PYLIBVER ?= python$(PYTHON_VERSION) - -AM_CPPFLAGS = -I. -I${top_srcdir} -I/usr/include/$(PYLIBVER) - -DEPENDENCIES = \ - ${top_srcdir}/snapper/Factory.h \ - ${top_srcdir}/snapper/Snapper.h \ - ${top_srcdir}/snapper/Snapshot.h \ - ${top_srcdir}/snapper/File.h \ - ${top_srcdir}/snapper/Comparison.h \ - ${top_srcdir}/snapper/Exception.h - -LIBS = $(top_builddir)/snapper/libsnapper.la - -python_PYTHON = libsnapper.py - -pyexec_LTLIBRARIES = _libsnapper.la - -_libsnapper_la_LDFLAGS = -module -avoid-version -_libsnapper_la_HEADERS: $(top_builddir)/config.h - -_libsnapper_la_DEPENDENCIES = \ - $(DEPENDENCIES) \ - ${top_builddir}/snapper/libsnapper.la - -nodist__libsnapper_la_SOURCES = libsnapper_wrap.cxx - -libsnapper.py libsnapper_wrap.cxx: libsnapper.i $(DEPENDENCIES) - swig -o libsnapper_wrap.cxx -c++ -python ${AM_CPPFLAGS} libsnapper.i - -CLEANFILES = libsnapper.py libsnapper_wrap.cxx diff --git a/bindings/python/examples/create.py b/bindings/python/examples/create.py deleted file mode 100755 index 2cabdcd0..00000000 --- a/bindings/python/examples/create.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/python - -import libsnapper - - -sh = libsnapper.createSnapper("root", False) - -sh.createSingleSnapshot("python test") - -libsnapper.deleteSnapper(sh) - diff --git a/bindings/python/examples/test.py b/bindings/python/examples/test.py deleted file mode 100755 index caedb82e..00000000 --- a/bindings/python/examples/test.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/python - -import libsnapper - -def print_snap_info( s ): - if isinstance( s, libsnapper.SwigPyIterator ): - try: - s = s.value() - except StopIteration: - print "end iterator" - return - print s.getNum(), s.getType(), s.getDescription() - -sh = libsnapper.createSnapper("root", False) - -# testing getConfigs -cl = libsnapper.Snapper.getConfigs() -print cl.size() -for i in cl: print i.config_name, i.subvolume - -# testing getIgnorePatterns -pl = sh.getIgnorePatterns() -print pl.size() -for i in pl: print i - -# testing iterators over container -sl = sh.getSnapshots() -for i in sl: print_snap_info( i ) -print sl.size() -i = sl.begin() -while i!=sl.end(): - print_snap_info( i ) - i.incr() - -# testing find functions -i = sl.find(3) -print_snap_info( i ) -i = sl.getSnapshotCurrent() -print_snap_info( i ) -i = sl.find(11) -print_snap_info( i ) -j = sl.findPre(i) -print_snap_info( j ) -i = sl.find(10) -print_snap_info( i ) - -# testing handling description -j = sl.findPost(i) -print_snap_info( j ) -s=j.value().getDescription() -j.value().setDescription(s+" 1") -j = sl.findPost(i) -print_snap_info( j ) -s=j.value().getDescription() -j.value().setDescription(s[:-2]) - -# testing handling userdata -j = sl.findPost(i) -print_snap_info( j ) -s=j.value().getUserdata() -print s.items() -s["key1"] = "value1" -s["key2"] = "value2" -s["key3"] = "value3" -j.value().setUserdata(s) -j = sl.findPost(i) -print_snap_info( j ) -t=j.value().getUserdata() -print t.items() -t.clear() -j.value().setUserdata(t) -j = sl.findPost(i) -print_snap_info( j ) -print j.value().getUserdata().items() - -# testing compare functionality -j=sl.find(11); -i=sl.findPre(j); -cmp=libsnapper.Comparison(sh,i,j) -i1=cmp.getSnapshot1() -i2=cmp.getSnapshot2() -print_snap_info( i1 ) -print_snap_info( i2 ) -flist=cmp.getFiles() -print flist.size() -for f in flist: - print f.getAbsolutePath(libsnapper.LOC_SYSTEM), f.getAbsolutePath(libsnapper.LOC_PRE), f.getAbsolutePath(libsnapper.LOC_POST) - sl = f.getDiff("-u") - for s in sl: print s - -# testing set/getUndo -f=flist.begin() -if f != flist.end(): - print f.value().getUndo() - f.value().setUndo(True) - print f.value().getUndo() - f.value().setUndo(False) - print f.value().getUndo() - f.value().setUndo(True) - print f.value().getUndo() - -# testing doUndo -if f != flist.end(): - print cmp.doUndo() diff --git a/bindings/python/libsnapper.i b/bindings/python/libsnapper.i deleted file mode 100644 index 3db2b15b..00000000 --- a/bindings/python/libsnapper.i +++ /dev/null @@ -1,251 +0,0 @@ -// -// Python interface definition for libsnapper -// - -%module libsnapper - -%{ -using namespace std; - -#include -#include -#include -#include -#include -#include -%} - -using namespace std; - -%include "std_string.i" -%include "std_vector.i" -%include "std_list.i" -%include "std_map.i" - -%typemap(out) std::string* { - $result = PyString_FromString($1->c_str()); -} - -%ignore snapper::Snapshots::begin(); -%ignore snapper::Snapshots::begin() const; -%ignore snapper::Snapshots::end(); -%ignore snapper::Snapshots::end() const; -%ignore snapper::Snapshots::find(unsigned int); -%ignore snapper::Snapshots::find(unsigned int) const; -%ignore snapper::Snapshots::findPre(snapper::Snapshots::const_iterator); -%ignore snapper::Snapshots::findPre(snapper::Snapshots::const_iterator) const; -%ignore snapper::Snapshots::findPost(snapper::Snapshots::const_iterator); -%ignore snapper::Snapshots::findPost(snapper::Snapshots::const_iterator) const; -%ignore snapper::Snapshots::getSnapshotCurrent() const; -%ignore snapper::Comparison::getSnapshot1() const; -%ignore snapper::Comparison::getSnapshot2() const; -%ignore snapper::Files::begin(); -%ignore snapper::Files::begin() const; -%ignore snapper::Files::end(); -%ignore snapper::Files::end() const; -%ignore snapper::Files::find(); -%ignore snapper::Files::find() const; -%ignore snapper::Files::findAbsolutePath(); -%ignore snapper::Files::findAbsolutePath() const; - -%include "../../snapper/Factory.h" -%include "../../snapper/Exception.h" -%include "../../snapper/Snapshot.h" -%include "../../snapper/Snapper.h" -%include "../../snapper/File.h" -%include "../../snapper/Comparison.h" - -using namespace snapper; - - -%template(vectorstring) std::vector; -%std_nodefconst_type(File); -%template(vectorFile) std::vector >; -%template(mapstringstring) std::map; -%template(pairstringstring) std::pair; -%template(paircstringstring) std::pair; -%std_nodefconst_type(ConfigInfo); -%template(listConfigInfo) std::list; -%std_nodefconst_type(Snapshot); -%template(listSnapshot) std::list >; - -%extend snapper::Snapshots { -%fragment("SwigPyIterator_T"); - -%{ -template -class MySwigPyIteratorTmpl : public swig::SwigPyIteratorClosed_T -{ -public: - typedef swig::SwigPyIteratorClosed_T base; - typedef typename It::value_type value_type; - - MySwigPyIteratorTmpl(It curr, It first, It last, PyObject *seq) - : swig::SwigPyIteratorClosed_T(curr,first,last,seq), nend(last) - {} - PyObject *value() const { - if (base::current == nend) { - throw swig::stop_iteration(); - } else { - value_type* p = const_cast(&(*base::current)); - return swig::from_ptr(p,0); - } - return NULL; - } -protected: - It nend; -}; - -typedef MySwigPyIteratorTmpl MySnapshotIt; -typedef MySwigPyIteratorTmpl MyCSnapshotIt; -typedef MySwigPyIteratorTmpl MyFileIt; -typedef MySwigPyIteratorTmpl MyCFileIt; -%} - -swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) - { - return new MySnapshotIt(self->begin(), self->begin(), - self->end(), *PYTHON_SELF); - } -swig::SwigPyIterator* begin(PyObject **PYTHON_SELF) - { - return new MySnapshotIt(self->begin(), self->begin(), - self->end(), *PYTHON_SELF); - } -swig::SwigPyIterator* end(PyObject **PYTHON_SELF) - { - return new MySnapshotIt(self->end(), self->begin(), - self->end(), *PYTHON_SELF); - } -swig::SwigPyIterator* find(PyObject **PYTHON_SELF,unsigned int num) - { - return new MySnapshotIt(self->find(num), self->begin(), - self->end(), *PYTHON_SELF); - } -swig::SwigPyIterator* findPre(PyObject **PYTHON_SELF, PyObject *pobj ) - { - swig::SwigPyIteratorClosed_T *it = NULL; - void *argp = 0; - int ret = SWIG_ConvertPtr(pobj, &argp, SWIGTYPE_p_swig__SwigPyIterator, 0 ); - if( SWIG_IsOK(ret)) - { - swig::SwigPyIterator *pi = reinterpret_cast(argp); - it = dynamic_cast *>(pi); - } - else - SWIG_exception_fail(SWIG_ArgError(ret), "in method '" "swig::SwigPyIterator* findPre" "', argument not of type swig::SwigPyIterator"); - - if( it ) - return new MySnapshotIt(self->findPre(it->get_current()), - self->begin(), self->end(), *PYTHON_SELF); - else - - SWIG_exception_fail( SWIG_ArgError(ret),"argument of wrong swig::SwigPyIterator derived class in method '" "swig::SwigPyIterator* findPre" "'" ); -fail: - return NULL; - } - -swig::SwigPyIterator* findPost(PyObject **PYTHON_SELF, PyObject *pobj ) - { - swig::SwigPyIteratorClosed_T *it = NULL; - void *argp = 0; - int ret = SWIG_ConvertPtr(pobj, &argp, SWIGTYPE_p_swig__SwigPyIterator, 0 ); - if( SWIG_IsOK(ret)) - { - swig::SwigPyIterator *pi = reinterpret_cast(argp); - it = dynamic_cast *>(pi); - } - else - SWIG_exception_fail(SWIG_ArgError(ret), "in method '" "swig::SwigPyIterator* findPre" "', argument not of type swig::SwigPyIterator"); - - if( it ) - return new MySnapshotIt(self->findPost(it->get_current()), - self->begin(), self->end(), *PYTHON_SELF); - else - - SWIG_exception_fail( SWIG_ArgError(ret),"argument of wrong swig::SwigPyIterator derived class in method '" "swig::SwigPyIterator* findPre" "'" ); -fail: - return NULL; - } - -swig::SwigPyIterator* getSnapshotCurrent(PyObject **PYTHON_SELF) - { - return new MySnapshotIt(self->begin(), self->begin(), - self->end(), *PYTHON_SELF); - } -} - -%extend snapper::Comparison { - -Comparison( const snapper::Snapper* sn, PyObject *pobj1, PyObject *pobj2 ) - { - swig::SwigPyIteratorClosed_T *it1 = NULL; - swig::SwigPyIteratorClosed_T *it2 = NULL; - void *argp = 0; - int ret = SWIG_ConvertPtr(pobj1, &argp, SWIGTYPE_p_swig__SwigPyIterator, 0 ); - if( SWIG_IsOK(ret)) - { - swig::SwigPyIterator *pi = reinterpret_cast(argp); - it1 = dynamic_cast *>(pi); - } - else - SWIG_exception_fail(SWIG_ArgError(ret), "in method '" "swig::SwigPyIterator* findPre" "', argument 2 not of type swig::SwigPyIterator"); - - ret = SWIG_ConvertPtr(pobj2, &argp, SWIGTYPE_p_swig__SwigPyIterator, 0 ); - if( SWIG_IsOK(ret)) - { - swig::SwigPyIterator *pi = reinterpret_cast(argp); - it2 = dynamic_cast *>(pi); - } - else - SWIG_exception_fail(SWIG_ArgError(ret), "in method '" "swig::SwigPyIterator* findPre" "', argument 3 not of type swig::SwigPyIterator"); - - if( it1 && it2 ) - return new snapper::Comparison( sn, it1->get_current(), it2->get_current() ); - else if( it1 ) - - SWIG_exception_fail( SWIG_ArgError(ret),"argument 3 of wrong swig::SwigPyIterator derived class in method '" "swig::SwigPyIterator* findPre" "'" ); - else - SWIG_exception_fail( SWIG_ArgError(ret),"argument 2 of wrong swig::SwigPyIterator derived class in method '" "swig::SwigPyIterator* findPre" "'" ); -fail: - return NULL; - } - -swig::SwigPyIterator* getSnapshot1(PyObject **PYTHON_SELF) - { - snapper::Snapshots::const_iterator c = self->getSnapshot1(); - snapper::Snapshots::const_iterator b = self->getSnapper()->getSnapshots().begin(); - snapper::Snapshots::const_iterator e = self->getSnapper()->getSnapshots().end(); - - return new MyCSnapshotIt(c, b, e, *PYTHON_SELF); - } - -swig::SwigPyIterator* getSnapshot2(PyObject **PYTHON_SELF) - { - snapper::Snapshots::const_iterator c = self->getSnapshot2(); - snapper::Snapshots::const_iterator b = self->getSnapper()->getSnapshots().begin(); - snapper::Snapshots::const_iterator e = self->getSnapper()->getSnapshots().end(); - - return new MyCSnapshotIt(c, b, e, *PYTHON_SELF); - } -} - -%extend snapper::Files { - -swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) - { - return new MyFileIt(self->begin(), self->begin(), - self->end(), *PYTHON_SELF); - } -swig::SwigPyIterator* begin(PyObject **PYTHON_SELF) - { - return new MyFileIt(self->begin(), self->begin(), - self->end(), *PYTHON_SELF); - } -swig::SwigPyIterator* end(PyObject **PYTHON_SELF) - { - return new MyFileIt(self->end(), self->begin(), - self->end(), *PYTHON_SELF); - } -} - -- 2.47.3