Esempio n. 1
0
File: core.py Progetto: 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
File: core.py Progetto: 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)
Esempio n. 4
0
    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)