mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	email-mirror.py: Make it pass on mypy in python 3.
* Replace filter by list comprehension. * Add '# type: ignore' to statements which use attributes from modeule `posix`, since stubs for posix are missing on python 3.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							17cb6e00bd
						
					
				
				
					commit
					896c18a57b
				
			@@ -41,7 +41,6 @@ exclude_py2 = []
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
exclude_py3 = """
 | 
					exclude_py3 = """
 | 
				
			||||||
zerver/lib/ccache.py
 | 
					zerver/lib/ccache.py
 | 
				
			||||||
zerver/management/commands/email-mirror.py
 | 
					 | 
				
			||||||
zerver/management/commands/enqueue_file.py
 | 
					zerver/management/commands/enqueue_file.py
 | 
				
			||||||
zerver/management/commands/rename_stream.py
 | 
					zerver/management/commands/rename_stream.py
 | 
				
			||||||
zerver/management/commands/runtornado.py
 | 
					zerver/management/commands/runtornado.py
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -109,7 +109,7 @@ def examine_mailbox(result, proto, mailbox):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def select_mailbox(result, proto):
 | 
					def select_mailbox(result, proto):
 | 
				
			||||||
    # Select which mailbox we care about.
 | 
					    # Select which mailbox we care about.
 | 
				
			||||||
    mbox = filter(lambda x: settings.EMAIL_GATEWAY_IMAP_FOLDER in x[2], result)[0][2]
 | 
					    mbox = [x for x in result if settings.EMAIL_GATEWAY_IMAP_FOLDER in x[2]][0][2]
 | 
				
			||||||
    return proto.select(mbox).addCallback(examine_mailbox, proto, result)
 | 
					    return proto.select(mbox).addCallback(examine_mailbox, proto, result)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def list_mailboxes(res, proto):
 | 
					def list_mailboxes(res, proto):
 | 
				
			||||||
@@ -153,13 +153,13 @@ class Command(BaseCommand):
 | 
				
			|||||||
                    mark_missed_message_address_as_used(rcpt_to)
 | 
					                    mark_missed_message_address_as_used(rcpt_to)
 | 
				
			||||||
                except ZulipEmailForwardError:
 | 
					                except ZulipEmailForwardError:
 | 
				
			||||||
                    print("5.1.1 Bad destination mailbox address: Bad or expired missed message address.")
 | 
					                    print("5.1.1 Bad destination mailbox address: Bad or expired missed message address.")
 | 
				
			||||||
                    exit(posix.EX_NOUSER)
 | 
					                    exit(posix.EX_NOUSER) # type: ignore # There are no stubs for posix in python 3
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    extract_and_validate(rcpt_to)
 | 
					                    extract_and_validate(rcpt_to)
 | 
				
			||||||
                except ZulipEmailForwardError:
 | 
					                except ZulipEmailForwardError:
 | 
				
			||||||
                    print("5.1.1 Bad destination mailbox address: Please use the address specified in your Streams page.")
 | 
					                    print("5.1.1 Bad destination mailbox address: Please use the address specified in your Streams page.")
 | 
				
			||||||
                    exit(posix.EX_NOUSER)
 | 
					                    exit(posix.EX_NOUSER) # type: ignore # There are no stubs for posix in python 3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Read in the message, at most 25MiB. This is the limit enforced by
 | 
					            # Read in the message, at most 25MiB. This is the limit enforced by
 | 
				
			||||||
            # Gmail, which we use here as a decent metric.
 | 
					            # Gmail, which we use here as a decent metric.
 | 
				
			||||||
@@ -168,7 +168,7 @@ class Command(BaseCommand):
 | 
				
			|||||||
            if len(sys.stdin.read(1)) != 0:
 | 
					            if len(sys.stdin.read(1)) != 0:
 | 
				
			||||||
                # We're not at EOF, reject large mail.
 | 
					                # We're not at EOF, reject large mail.
 | 
				
			||||||
                print("5.3.4 Message too big for system: Max size is 25MiB")
 | 
					                print("5.3.4 Message too big for system: Max size is 25MiB")
 | 
				
			||||||
                exit(posix.EX_DATAERR)
 | 
					                exit(posix.EX_DATAERR) # type: ignore # There are no stubs for posix in python 3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            queue_json_publish(
 | 
					            queue_json_publish(
 | 
				
			||||||
                    "email_mirror",
 | 
					                    "email_mirror",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user