From 072dec7bc44446af41fcc5ba0af9f8b0adc82559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=92=D0=BB=D0=B0?= =?UTF-8?q?=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Thu, 18 Feb 2016 13:50:28 +0300 Subject: [PATCH] savedata methods --- src/tox.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/tox.py b/src/tox.py index 1132e1d..0857a28 100644 --- a/src/tox.py +++ b/src/tox.py @@ -63,7 +63,7 @@ class Tox(object): # creating tox object tox_err = c_int() self.libtoxcore.tox_new.restype = POINTER(c_void_p) - self.tox_pointer = self.libtoxcore.tox_new(self.tox_options, tox_err) + self._tox_pointer = self.libtoxcore.tox_new(self.tox_options, tox_err) if tox_err == TOX_ERR_NEW['TOX_ERR_NEW_NULL']: raise ArgumentError('One of the arguments to the function was NULL when it was not expected.') elif tox_err == TOX_ERR_NEW['TOX_ERR_NEW_MALLOC']: @@ -89,9 +89,19 @@ class Tox(object): ' formatted data, some data may have been loaded, and the rest is discarded. Passing' ' an invalid length parameter also causes this error.') + def get_savedata_size(self): + return self.libtoxcore.tox_get_savedata_size(self._tox_pointer) + + def get_savedata(self, savedata=None): + if savedata is None: + savedata_size = self.get_savedata_size() + savedata = create_string_buffer(savedata_size) + self.libtoxcore.tox_get_savedata(self._tox_pointer, savedata) + return savedata + def __del__(self): + self.libtoxcore.tox_kill(self._tox_pointer) self.libtoxcore.tox_options_free(self.tox_options) - self.libtoxcore.tox_kill(self.tox_pointer) if __name__ == '__main__':