def new_from_filepart(self, file, offset, length): """This wraps the GPGME gpgme_data_new_from_filepart() function. The argument "file" may be: 1. a string specifying a file name, or 3. a a file-like object. supporting the fileno() call and the mode attribute.""" tmp = pygpgme.new_gpgme_data_t_p() filename = None fp = None if type(file) == type("x"): filename = file else: fp = pygpgme.fdopen(file.fileno(), file.mode) if fp == None: raise ValueError, "Failed to open file from %s arg %s" % \ (str(type(file)), str(file)) errorcheck( pygpgme.gpgme_data_new_from_filepart(tmp, filename, fp, offset, length)) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)
def new_from_cbs(self, funcs, hook): """Argument funcs must be a 4 element tuple with callbacks: (read_cb, write_cb, seek_cb, release_cb)""" tmp = pygpgme.new_gpgme_data_t_p() self._free_readcb() self.last_readcb = pygpgme.new_PyObject_p_p() hookdata = (funcs, hook) pygpgme.pygpgme_data_new_from_cbs(tmp, hookdata, self.last_readcb) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)
def new_from_fd(self, file): """This wraps the GPGME gpgme_data_new_from_fd() function. The argument "file" may be a file-like object, supporting the fileno() call and the mode attribute.""" tmp = pygpgme.new_gpgme_data_t_p() fp = pygpgme.fdopen(file.fileno(), file.mode) if fp == None: raise ValueError, "Failed to open file from %s arg %s" % \ (str(type(file)), str(file)) errorcheck(gpgme_data_new_from_fd(tmp, fp)) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)
def new_from_filepart(self, file, offset, length): """This wraps the GPGME gpgme_data_new_from_filepart() function. The argument "file" may be: 1. a string specifying a file name, or 3. a a file-like object. supporting the fileno() call and the mode attribute.""" tmp = pygpgme.new_gpgme_data_t_p() filename = None fp = None if type(file) == type("x"): filename = file else: fp = pygpgme.fdopen(file.fileno(), file.mode) if fp == None: raise ValueError, "Failed to open file from %s arg %s" % \ (str(type(file)), str(file)) errorcheck(pygpgme.gpgme_data_new_from_filepart(tmp, filename, fp, offset, length)) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)
def new_from_file(self, filename, copy = 1): tmp = pygpgme.new_gpgme_data_t_p() errorcheck(pygpgme.gpgme_data_new_from_file(tmp, filename, copy)) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)
def new_from_mem(self, string, copy = 1): tmp = pygpgme.new_gpgme_data_t_p() errorcheck(pygpgme.gpgme_data_new_from_mem(tmp,string,len(string),copy)) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)
def new(self): tmp = pygpgme.new_gpgme_data_t_p() errorcheck(pygpgme.gpgme_data_new(tmp)) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)
def new_from_file(self, filename, copy=1): tmp = pygpgme.new_gpgme_data_t_p() errorcheck(pygpgme.gpgme_data_new_from_file(tmp, filename, copy)) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)
def new_from_mem(self, string, copy=1): tmp = pygpgme.new_gpgme_data_t_p() errorcheck( pygpgme.gpgme_data_new_from_mem(tmp, string, len(string), copy)) self.wrapped = pygpgme.gpgme_data_t_p_value(tmp) pygpgme.delete_gpgme_data_t_p(tmp)