@@ -103,7 +103,7 @@ class node. Any parts of other types are each stored in separate files
103103import email .utils
104104from email .generator import Generator
105105
106- from .anypy .email_ import decode_header
106+ from roundup .anypy .email_ import decode_header , message_from_bytes
107107from roundup .anypy .my_input import my_input
108108
109109from roundup import configuration , hyperdb , date , password , exceptions
@@ -114,9 +114,9 @@ class node. Any parts of other types are each stored in separate files
114114import roundup .anypy .random_ as random_
115115
116116try :
117- import pyme , pyme .core , pyme .constants , pyme .constants .sigsum
117+ import gpg , gpg .core , gpg .constants , gpg .constants .sigsum
118118except ImportError :
119- pyme = None
119+ gpg = None
120120
121121SENDMAILDEBUG = os .environ .get ('SENDMAILDEBUG' , '' )
122122
@@ -173,18 +173,18 @@ def check_pgp_sigs(sigs, gpgctx, author, may_be_unsigned=False):
173173 # we really only care about the signature of the user who
174174 # submitted the email
175175 if key and (author in gpgh_key_getall (key , 'email' )):
176- if sig .summary & pyme .constants .sigsum .VALID :
176+ if sig .summary & gpg .constants .sigsum .VALID :
177177 return True
178178 else :
179179 # try to narrow down the actual problem to give a more useful
180180 # message in our bounce
181- if sig .summary & pyme .constants .sigsum .KEY_MISSING :
181+ if sig .summary & gpg .constants .sigsum .KEY_MISSING :
182182 raise MailUsageError ( \
183183 _ ("Message signed with unknown key: %s" ) % sig .fpr )
184- elif sig .summary & pyme .constants .sigsum .KEY_EXPIRED :
184+ elif sig .summary & gpg .constants .sigsum .KEY_EXPIRED :
185185 raise MailUsageError ( \
186186 _ ("Message signed with an expired key: %s" ) % sig .fpr )
187- elif sig .summary & pyme .constants .sigsum .KEY_REVOKED :
187+ elif sig .summary & gpg .constants .sigsum .KEY_REVOKED :
188188 raise MailUsageError ( \
189189 _ ("Message signed with a revoked key: %s" ) % sig .fpr )
190190 else :
@@ -415,9 +415,9 @@ def decrypt(self, author, may_be_unsigned=False):
415415 hdr .get_content_type () != 'application/pgp-encrypted' ):
416416 raise MailUsageError (_ ("Unknown multipart/encrypted version." ))
417417
418- context = pyme .core .Context ()
419- ciphertext = pyme .core .Data (msg .get_payload ())
420- plaintext = pyme .core .Data ()
418+ context = gpg .core .Context ()
419+ ciphertext = gpg .core .Data (msg .get_payload ())
420+ plaintext = gpg .core .Data ()
421421
422422 result = context .op_decrypt_verify (ciphertext , plaintext )
423423
@@ -432,10 +432,10 @@ def decrypt(self, author, may_be_unsigned=False):
432432 may_be_unsigned = may_be_unsigned )
433433
434434 plaintext .seek (0 , 0 )
435- # pyme .core.Data implements a seek method with a different signature
435+ # gpg .core.Data implements a seek method with a different signature
436436 # than roundup can handle. So we'll put the data in a container that
437437 # the Message class can work with.
438- return email . message_from_string (plaintext .read (), RoundupMessage )
438+ return message_from_bytes (plaintext .read (), RoundupMessage )
439439
440440 def verify_signature (self , author ):
441441 """
@@ -458,10 +458,10 @@ def verify_signature(self, author):
458458 # canonical <CR><LF> sequence."
459459 # TODO: what about character set conversion?
460460 canonical_msg = re .sub ('(?<!\r )\n ' , '\r \n ' , msg .flatten ())
461- msg_data = pyme .core .Data (canonical_msg )
462- sig_data = pyme .core .Data (sig .get_payload ())
461+ msg_data = gpg .core .Data (canonical_msg )
462+ sig_data = gpg .core .Data (sig .get_payload ())
463463
464- context = pyme .core .Context ()
464+ context = gpg .core .Context ()
465465 context .op_verify (sig_data , msg_data , None )
466466
467467 # check all signatures for validity
@@ -942,7 +942,7 @@ def pgp_role():
942942 if self .config .PGP_ENABLE :
943943 if pgp_role () and self .config .PGP_ENCRYPT :
944944 self .crypt = True
945- assert pyme , 'pyme is not installed'
945+ assert gpg , 'gpg is not installed'
946946 # signed/encrypted mail must come from the primary address
947947 author_address = self .db .user .get (self .author , 'address' )
948948 if self .config .PGP_HOMEDIR :
0 commit comments