Skip to content

Commit

Permalink
Cosmetic, s/mail/sender, s/data/content, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Bates committed Aug 10, 2011
1 parent ca64637 commit 9faed09
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 115 deletions.
34 changes: 17 additions & 17 deletions cookie
Expand Up @@ -74,8 +74,8 @@ def _():

ctx.recipient = [].append

def mail(ctx, mailbox):
ctx.sender = mailbox
def sender(ctx, sender):
ctx.sender = sender

@promise.continuate
def start(ctx, command, state):
Expand Down Expand Up @@ -108,10 +108,10 @@ def _():
raise StopIteration(state((yield ctx.ctx.command()), state))

@promise.continuate
def data(ctx, data):
def content(ctx, content):
if (yield ctx.ctx.reset):
try:
rsetReply = yield ctx.ctx.client.rsetCmd()
rsetReply = yield ctx.ctx.client.rset()

except smtp.reply as e:
ctx.ctx.transport.write(str(e))
Expand All @@ -133,12 +133,12 @@ def _():
timeStampLine = qwer('Received:', rfc5322.FWS, stamp, rfc5234.CRLF)

try:
timeStampLine.match(data)
timeStampLine.match(content)

# Not authenticated, ESMTPA
except ValueError:
try:
messageId = rfc5322.messageId.search(data, 'idLeft, idRight')
messageId = rfc5322.messageId.search(content, 'idLeft, idRight')

except ValueError:
pass
Expand All @@ -153,7 +153,7 @@ def _():
cursor.execute('INSERT INTO message_id (message_id, sender) VALUES (%s, %s)', messageId.join('@'), recipient.localPart)

try:
mailReply = yield mail.mailCmd(ctx.sender)
mailReply = yield mail.mail(ctx.sender)

except smtp.reply as e:
ctx.ctx.transport.write(str(e))
Expand All @@ -163,7 +163,7 @@ def _():

for recipient in ctx.recipient.__self__:
try:
yield mail.rcptCmd(recipient)
yield mail.rcpt(recipient)

except smtp.reply as e:
ctx.ctx.reset = True
Expand All @@ -174,7 +174,7 @@ def _():
raise StopIteration(ctx.afterRecipient((yield ctx.ctx.command()), ctx.afterRecipient))

try:
dataReply = yield mail.dataCmd(data)
dataReply = yield mail.data(content)

except smtp.reply as e:

Expand Down Expand Up @@ -208,7 +208,7 @@ def _():

def messageId(qwer):
try:
msgId = qwer.search(data, 'msgId ( idLeft, idRight )')
msgId = qwer.search(content, 'msgId ( idLeft, idRight )')

except ValueError:
raise Exception
Expand Down Expand Up @@ -242,7 +242,7 @@ def _():
@promise.continuate
def send(*recipient):
try:
mailReply = yield mail.mailCmd(sender + '@nottheoilrig.com')
mailReply = yield mail.mail(sender + '@nottheoilrig.com')

# Client only raises reply if unexpected/unsuccessful
except smtp.reply as e:
Expand All @@ -253,7 +253,7 @@ def _():

for itm in recipient:
try:
yield mail.rcptCmd(itm)
yield mail.rcpt(itm)

# Client only raises reply if unexpected/unsuccessful
except smtp.reply as e:
Expand All @@ -266,7 +266,7 @@ def _():

try:
#return ...
raise StopIteration(mail.dataCmd(rfc5322.From.replace(untwisted.partial(replace, sender), data, 'mailbox ( nameAddr, displayName, CFWS, localPart, dotAtomText, DQUOTE, domain )', count=1)))
raise StopIteration(mail.data(rfc5322.From.replace(untwisted.partial(replace, sender), content, 'mailbox ( nameAddr, displayName, CFWS, localPart, dotAtomText, DQUOTE, domain )', count=1)))

# Client only raises reply if unexpected/unsuccessful
except smtp.reply as e:
Expand Down Expand Up @@ -326,7 +326,7 @@ def _():
for recipient in rest:
if reset:
try:
rsetReply = yield ctx.ctx.client.rsetCmd()
rsetReply = yield ctx.ctx.client.rset()

except smtp.reply:

Expand All @@ -338,12 +338,12 @@ def _():
sender = address(recipient)

try:
mailReply = yield mail.mailCmd(sender + '@nottheoilrig.com')
mailReply = yield mail.mail(sender + '@nottheoilrig.com')

try:
yield mail.rcptCmd(recipient)
yield mail.rcpt(recipient)

yield mail.dataCmd(rfc5322.From.replace(untwisted.partial(replace, sender), data, 'mailbox ( nameAddr, displayName, CFWS, localPart, dotAtomText, DQUOTE, domain )', count=1))
yield mail.data(rfc5322.From.replace(untwisted.partial(replace, sender), content, 'mailbox ( nameAddr, displayName, CFWS, localPart, dotAtomText, DQUOTE, domain )', count=1))

except smtp.reply:

Expand Down
14 changes: 7 additions & 7 deletions test/addAddress
Expand Up @@ -17,19 +17,19 @@ def _():
ctx = yield

class sample(smtp.server.mail):
def mail(ctx, mailbox):
ctx.sender = mailbox
def sender(ctx, sender):
ctx.sender = sender

for cursor in conn:
equiv(((str(mailbox.localPart),),), cursor.execute('SELECT sender FROM address WHERE address = %s', 'bob@example.com'))
equiv(((str(sender.localPart),),), cursor.execute('SELECT sender FROM address WHERE address = %s', 'bob@example.com'))

recipient = staticmethod(untwisted.each(lambda: equal('bob@example.com', str((yield)))))
data = lambda ctx, data: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = lambda ctx, content: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTPA',
' for <notbob@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: ' + str(ctx.sender),
'',
'la di da')), data)
'la di da')), content)

ctx = yield sample.__get__(ctx)()

Expand All @@ -45,9 +45,9 @@ def _():
ctx = yield

class sample(smtp.client.mail):
mail = iter(('alice@example.com',)).next
sender = iter(('alice@example.com',)).next
recipient = iter(('bob@example.com',)).next
data = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTPA',
' for <notbob@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
Expand Down
8 changes: 4 additions & 4 deletions test/addMessageId
Expand Up @@ -19,9 +19,9 @@ def _():
ctx = yield

class sample(smtp.server.mail):
mail = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
sender = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('abc123@example.com', str((yield)))))
data = staticmethod(untwisted.each(lambda: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = staticmethod(untwisted.each(lambda: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTP',
' for <abc123@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
Expand All @@ -43,9 +43,9 @@ def _():
ctx = yield

class sample(smtp.client.mail):
mail = iter(('alice@example.com',)).next
sender = iter(('alice@example.com',)).next
recipient = iter(('abc123@example.com',)).next
data = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTP',
' for <abc123@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
Expand Down
18 changes: 9 additions & 9 deletions test/dataError
Expand Up @@ -17,11 +17,11 @@ def _():
ctx = yield

class sample(smtp.server.mail):
mail = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
sender = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('bob@example.com', str((yield)))))

@promise.continuate
def data(ctx, data):
def content(ctx, content):
ctx.ctx.transport.write(str(smtp.reply(456, 'Expect')))

command = yield ctx.ctx.command()
Expand All @@ -34,9 +34,9 @@ def _():
ctx = yield sample.__get__(ctx)()

class sample(smtp.server.mail):
mail = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
sender = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('bob@example.com', str((yield)))))
data = staticmethod(untwisted.each(lambda: equal('la di da', str((yield)))))
content = staticmethod(untwisted.each(lambda: equal('la di da', str((yield)))))

ctx = yield sample.__get__(ctx)()

Expand All @@ -52,20 +52,20 @@ def _():
ctx = yield

class sample(smtp.client.mail):
mail = iter(('alice@example.com',)).next
sender = iter(('alice@example.com',)).next
recipient = iter(('bob@example.com',)).next
data = iter(('la di da',)).next
content = iter(('la di da',)).next

@promise.continuate
def dataCmd(ctx, data):
def data(ctx, content):
try:
ok(False, (yield smtp.client.mail.dataCmd(ctx, data)))
ok(False, (yield smtp.client.mail.data(ctx, content)))

except smtp.reply as e:
equal('456 Expect\r\n', str(e))

#return ...
raise StopIteration(smtp.client.mail.dataCmd(ctx, data))
raise StopIteration(smtp.client.mail.data(ctx, content))

yield sample.__get__(ctx)()

Expand Down
10 changes: 5 additions & 5 deletions test/dataReply
Expand Up @@ -17,10 +17,10 @@ def _():
ctx = yield

class sample(smtp.server.mail):
mail = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
sender = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('bob@example.com', str((yield)))))

def data(ctx, data):
def content(ctx, content):
raise smtp.reply(234, 'Expect')

ctx = yield sample.__get__(ctx)()
Expand All @@ -37,10 +37,10 @@ def _():
ctx = yield

class sample(smtp.client.mail):
mail = iter(('alice@example.com',)).next
sender = iter(('alice@example.com',)).next
recipient = iter(('bob@example.com',)).next
data = iter(('la di da',)).next
dataCmd = promise.compose(untwisted.partial(equal, '234 Expect\r\n'), str, smtp.client.mail.dataCmd)
content = iter(('la di da',)).next
data = promise.compose(untwisted.partial(equal, '234 Expect\r\n'), str, smtp.client.mail.data)

yield sample.__get__(ctx)()

Expand Down
8 changes: 4 additions & 4 deletions test/from
Expand Up @@ -19,9 +19,9 @@ def _():
ctx = yield

class sample(smtp.server.mail):
mail = staticmethod(untwisted.each(lambda: equal('abc123@nottheoilrig.com', str((yield)))))
sender = staticmethod(untwisted.each(lambda: equal('abc123@nottheoilrig.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('bob@example.com', str((yield)))))
data = staticmethod(untwisted.each(lambda: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = staticmethod(untwisted.each(lambda: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTPA',
' for <notbob@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: abc123@nottheoilrig.com',
Expand All @@ -42,9 +42,9 @@ def _():
ctx = yield

class sample(smtp.client.mail):
mail = iter(('alice@example.com',)).next
sender = iter(('alice@example.com',)).next
recipient = iter(('bob@example.com',)).next
data = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTPA',
' for <notbob@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
Expand Down
4 changes: 2 additions & 2 deletions test/httpAdd
Expand Up @@ -17,9 +17,9 @@ def _():

ctx.endHeaders()

def handleResponse(ctx, response):
def handleResponse(ctx, body):
for cursor in conn:
equiv(((response,),), cursor.execute('SELECT sender FROM address WHERE address = %s', 'bob@example.com'))
equiv(((body,),), cursor.execute('SELECT sender FROM address WHERE address = %s', 'bob@example.com'))

reactor.connectTCP('localhost', 8743, factory)

Expand Down
4 changes: 2 additions & 2 deletions test/httpBad
Expand Up @@ -17,10 +17,10 @@ def _():

ctx.endHeaders()

def handleResponse(ctx, response):
def handleResponse(ctx, body):
pass

handleStatus = lambda ctx, version, status, message: equal('404', status)
handleStatus = lambda ctx, version, code, phrase: equal('404', code)

reactor.connectTCP('localhost', 8743, factory)

Expand Down
8 changes: 4 additions & 4 deletions test/ignoreAddress
Expand Up @@ -19,9 +19,9 @@ def _():
ctx = yield

class sample(smtp.server.mail):
mail = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
sender = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('abc123@example.com', str((yield)))))
data = staticmethod(untwisted.each(lambda: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = staticmethod(untwisted.each(lambda: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTP',
' for <abc123@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
Expand All @@ -42,9 +42,9 @@ def _():
ctx = yield

class sample(smtp.client.mail):
mail = iter(('alice@example.com',)).next
sender = iter(('alice@example.com',)).next
recipient = iter(('abc123@example.com',)).next
data = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTP',
' for <abc123@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
Expand Down
8 changes: 4 additions & 4 deletions test/inReplyTo
Expand Up @@ -19,9 +19,9 @@ def _():
ctx = yield

class sample(smtp.server.mail):
mail = staticmethod(untwisted.each(lambda: equal('abc123@nottheoilrig.com', str((yield)))))
sender = staticmethod(untwisted.each(lambda: equal('abc123@nottheoilrig.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('bob@example.com', str((yield)))))
data = staticmethod(untwisted.each(lambda: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = staticmethod(untwisted.each(lambda: equal('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTPA',
' for <notbob@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: abc123@nottheoilrig.com',
Expand All @@ -43,9 +43,9 @@ def _():
ctx = yield

class sample(smtp.client.mail):
mail = iter(('alice@example.com',)).next
sender = iter(('alice@example.com',)).next
recipient = iter(('bob@example.com',)).next
data = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
content = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTPA',
' for <notbob@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
Expand Down

0 comments on commit 9faed09

Please sign in to comment.