(self, keyid, expiration_time='1y', passphrase=None, expire_subkeys=True)
return result
Changes GnuPG key expiration by passing in new time period (from now) through
            subprocess's stdin

        >>> import gnupg
        >>> gpg = gnupg.GPG(homedir="doctests")
        >>> key_input = gpg.gen_key_input()
        >>> key = gpg.gen_key(key_input)
        >>> gpg.expire(key.fingerprint, '2w', 'good passphrase')

        :param str keyid: key shortID, longID, email_address or fingerprint
        :param str expiration_time: 0 or number of days (d), or weeks (*w) , or months (*m)
                or years (*y) for when to expire the key, from today.
        :param str passphrase: passphrase used when creating the key, leave None otherwise
        :param bool expire_subkeys: to indicate whether the subkeys will also change the
                expiration time by the same period -- default is True

        :returns: The result giving status of the change in expiration...
                the new expiration date can be obtained by .list_keys()
Changes GnuPG key expiration by passing in new time period (from now) through
            subprocess's stdin
Changes GnuPG key expiration by passing in new time period ( from now ) through subprocess s stdin
def expire(self, keyid, expiration_time='1y', passphrase=None, expire_subkeys=True):
        """Changes GnuPG key expiration by passing in new time period (from now) through
            subprocess's stdin

        >>> import gnupg
        >>> gpg = gnupg.GPG(homedir="doctests")
        >>> key_input = gpg.gen_key_input()
        >>> key = gpg.gen_key(key_input)
        >>> gpg.expire(key.fingerprint, '2w', 'good passphrase')

        :param str keyid: key shortID, longID, email_address or fingerprint
        :param str expiration_time: 0 or number of days (d), or weeks (*w) , or months (*m)
                or years (*y) for when to expire the key, from today.
        :param str passphrase: passphrase used when creating the key, leave None otherwise
        :param bool expire_subkeys: to indicate whether the subkeys will also change the
                expiration time by the same period -- default is True

        :returns: The result giving status of the change in expiration...
                the new expiration date can be obtained by .list_keys()
        """

        passphrase = passphrase.encode(self._encoding) if passphrase else passphrase

        try:
            sub_keys_number = len(self.list_sigs(keyid)[0]['subkeys']) if expire_subkeys else 0
        except IndexError:
            sub_keys_number = 0

        expiration_input = KeyExpirationInterface(expiration_time, passphrase).gpg_interactive_input(sub_keys_number)

        args = ["--command-fd 0", "--edit-key %s" % keyid]
        p = self._open_subprocess(args)
        p.stdin.write(b(expiration_input))

        result = self._result_map['expire'](self)
        p.stdin.write(b(expiration_input))

        self._collect_output(p, result, stdin=p.stdin)
        return result
def expire ( self , keyid , expiration_time = '1y' , passphrase = None , expire_subkeys = True ) : passphrase = passphrase . encode ( self . _encoding ) if passphrase else passphrase try : sub_keys_number = len ( self . list_sigs ( keyid ) [ 0 ] [ 'subkeys' ] ) if expire_subkeys else 0 except IndexError : sub_keys_number = 0 expiration_input = KeyExpirationInterface ( expiration_time , passphrase ) . gpg_interactive_input ( sub_keys_number ) args = [ "--command-fd 0" , "--edit-key %s" % keyid ] p = self . _open_subprocess ( args ) p . stdin . write ( b ( expiration_input ) ) result = self . _result_map [ 'expire' ] ( self ) p . stdin . write ( b ( expiration_input ) ) self . _collect_output ( p , result , stdin = p . stdin ) return result