3 e\c@sddlmZmZmZddlmZddlmZ[[[dZdZej de [Gddde Z Gd d d e Z d!d d ZGd dde eZGddde ZGdddeZGddde ZGdddeZGddde ZGdddeZGddde ZGdddeZGdd d eZdS)")absolute_importprint_functionunicode_literals)gpgme)utilNZGPG_ERR_c@sReZdZdZdddZeddZeddZed d Zed d Z d dZ dS)GpgErrora>A GPG Error This is the base of all errors thrown by this library. If the error originated from GPGME, then additional information can be found by looking at 'code' for the error code, and 'source' for the errors origin. Suitable constants for comparison are defined in this module. 'code_str' and 'source_str' are human-readable versions of the former two properties. If 'context' is not None, then it contains a human-readable hint as to where the error originated from. If 'results' is not None, it is a tuple containing results of the operation that failed. The tuples elements are the results of the function that raised the error. Some operations return results even though they signal an error. Of course this information must be taken with a grain of salt. But often, this information is useful for diagnostic uses or to give the user feedback. Since the normal control flow is disrupted by the exception, the callee can no longer return results, hence we attach them to the exception objects. NcCs||_||_||_dS)N)errorcontextresults)selfr r r r /usr/lib64/python3.6/errors.py__init__=szGpgError.__init__cCs|jdkrdStj|jS)N)r rZgpgme_err_code)r r r rcodeBs z GpgError.codecCs|jdkrdStj|jS)N)r rgpgme_strerror)r r r rcode_strHs zGpgError.code_strcCs|jdkrdStj|jS)N)r rZgpgme_err_source)r r r rsourceNs zGpgError.sourcecCs|jdkrdStj|jS)N)r rZgpgme_strsource)r r r r source_strTs zGpgError.source_strcCsFg}|jdk r|j|j|jdk r<|j|j|j|jdj|S)Nz: )r appendr rrjoin)r Zmsgsr r r__str__Zs     zGpgError.__str__)NNN) __name__ __module__ __qualname____doc__rpropertyrrrrrr r r rr#s     rc@s@eZdZdZeddZeddZddZdd Z d d Z d S) GPGMEErrorzGeneric error This is a generic error that wraps the underlying libraries native error type. It is thrown when the low-level API is invoked and returns an error. This is the error that was used in PyME. cCs |tjS)N)rZgpgme_err_code_from_syserror)clsr r r fromSyserrormszGPGMEError.fromSyserrorcCs|jS)N)r )r r r rmessageqszGPGMEError.messagecCst|S)N)str)r r r r getstringuszGPGMEError.getstringcCs|jS)N)r)r r r rgetcodexszGPGMEError.getcodecCs|jS)N)r)r r r r getsource{szGPGMEError.getsourceN) rrrr classmethodrrr r"r#r$r r r rrds   rcCs|rt||dS)N)r)ZretvalZ extradatar r r errorchecksr&c@s eZdZdZddZddZdS) KeyNotFoundzRaised if a key was not found GPGME indicates this condition with EOF, which is not very idiomatic. We raise this error that is both a GPGMEError indicating EOF, and a KeyError. cCs||_tj|tdS)N)keystrrrEOF)r r(r r rrszKeyNotFound.__init__cCs|jS)N)r()r r r rrszKeyNotFound.__str__N)rrrrrrr r r rr'sr'c@s eZdZdS)EncryptionErrorN)rrrr r r rr*sr*c@seZdZddZddZdS)InvalidRecipientscKstj|f|||_dS)N)r*r recipients)r r,kwargsr r rrszInvalidRecipients.__init__cCsdjdd|jDS)Nz, css$|]}dj|jtj|jVqdS)z{}: {}N)formatfprrrreason).0rr r r sz,InvalidRecipients.__str__..)rr,)r r r rrs zInvalidRecipients.__str__N)rrrrrr r r rr+sr+c@s eZdZdS)DecryptionErrorN)rrrr r r rr4sr4c@seZdZddZddZdS)UnsupportedAlgorithmcKstj|f|||_dS)N)r4r algorithm)r r6r-r r rrszUnsupportedAlgorithm.__init__cCs|jS)N)r6)r r r rrszUnsupportedAlgorithm.__str__N)rrrrrr r r rr5sr5c@s eZdZdS) SigningErrorN)rrrr r r rr7sr7c@seZdZddZddZdS)InvalidSignerscKstj|f|||_dS)N)r7rsigners)r r9r-r r rrszInvalidSigners.__init__cCsdjdd|jDS)Nz, css$|]}dj|jtj|jVqdS)z{}: {}N)r.r/rrr0)r1sr r rr3sz)InvalidSigners.__str__..)rr9)r r r rrs zInvalidSigners.__str__N)rrrrrr r r rr8sr8c@seZdZddZdS)VerificationErrorcKstj|f|||_dS)N)rrresult)r r<r-r r rrszVerificationError.__init__N)rrrrr r r rr;sr;c@seZdZddZdS) BadSignaturescCsdjdd|jjDS)Nz, css.|]&}|jtkrdj|jtj|jVqdS)z{}: {}N)ZstatusNO_ERRORr.r/rr)r1r:r r rr3sz(BadSignatures.__str__..)rr<Z signatures)r r r rrs zBadSignatures.__str__N)rrrrr r r rr=sr=c@seZdZddZddZdS)MissingSignaturescKstj||f|||_dS)N)r;rmissing)r r<r@r-r r rrszMissingSignatures.__init__cCsdjdd|jDS)Nz, css|]}|jdjVqdS)rN)Zsubkeysr/)r1kr r rr3sz,MissingSignatures.__str__..)rr@)r r r rrszMissingSignatures.__str__N)rrrrrr r r rr?sr?)N)Z __future__rrrrrr>r)Zprocess_constantsglobals Exceptionrrr&KeyErrorr'r*r+r4r5r7r8r;r=r?r r r rs(  A