예제 #1
0
파일: core.py 프로젝트: jcollie/pyme
    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)
예제 #2
0
파일: core.py 프로젝트: tierney/lockbox-py
 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)
예제 #3
0
파일: core.py 프로젝트: jcollie/pyme
 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)
예제 #4
0
파일: core.py 프로젝트: tierney/lockbox-py
 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)
예제 #5
0
파일: core.py 프로젝트: jcollie/pyme
    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)
예제 #6
0
파일: core.py 프로젝트: tierney/lockbox-py
    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)
예제 #7
0
파일: core.py 프로젝트: tierney/lockbox-py
 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)
예제 #8
0
파일: core.py 프로젝트: tierney/lockbox-py
 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)
예제 #9
0
파일: core.py 프로젝트: tierney/lockbox-py
 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)
예제 #10
0
파일: core.py 프로젝트: jcollie/pyme
 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)
예제 #11
0
파일: core.py 프로젝트: jcollie/pyme
 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)
예제 #12
0
파일: core.py 프로젝트: jcollie/pyme
 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)