MCPcopy Index your code
hub / github.com/python/cpython / found_terminator

Method found_terminator

Lib/test/support/smtpd.py:323–382  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

321
322 # Implementation of base class abstract method
323 def found_terminator(self):
324 line = self._emptystring.join(self.received_lines)
325 print('Data:', repr(line), file=DEBUGSTREAM)
326 self.received_lines = []
327 if self.smtp_state == self.COMMAND:
328 sz, self.num_bytes = self.num_bytes, 0
329 if not line:
330 self.push('500 Error: bad syntax')
331 return
332 if not self._decode_data:
333 line = str(line, 'utf-8')
334 i = line.find(' ')
335 if i < 0:
336 command = line.upper()
337 arg = None
338 else:
339 command = line[:i].upper()
340 arg = line[i+1:].strip()
341 max_sz = (self.command_size_limits[command]
342 if self.extended_smtp else self.command_size_limit)
343 if sz > max_sz:
344 self.push('500 Error: line too long')
345 return
346 method = getattr(self, 'smtp_' + command, None)
347 if not method:
348 self.push('500 Error: command "%s" not recognized' % command)
349 return
350 method(arg)
351 return
352 else:
353 if self.smtp_state != self.DATA:
354 self.push('451 Internal confusion')
355 self.num_bytes = 0
356 return
357 if self.data_size_limit and self.num_bytes > self.data_size_limit:
358 self.push('552 Error: Too much mail data')
359 self.num_bytes = 0
360 return
361 # Remove extraneous carriage returns and de-transparency according
362 # to RFC 5321, Section 4.5.2.
363 data = []
364 for text in line.split(self._linesep):
365 if text and text[0] == self._dotsep:
366 data.append(text[1:])
367 else:
368 data.append(text)
369 self.received_data = self._newline.join(data)
370 args = (self.peer, self.mailfrom, self.rcpttos, self.received_data)
371 kwargs = {}
372 if not self._decode_data:
373 kwargs = {
374 'mail_options': self.mail_options,
375 'rcpt_options': self.rcpt_options,
376 }
377 status = self.smtp_server.process_message(*args, **kwargs)
378 self._set_post_data_state()
379 if not status:
380 self.push('250 OK')

Callers

nothing calls this directly

Calls 11

pushMethod · 0.95
_set_post_data_stateMethod · 0.95
strFunction · 0.85
methodFunction · 0.85
joinMethod · 0.45
findMethod · 0.45
upperMethod · 0.45
stripMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45
process_messageMethod · 0.45

Tested by

no test coverage detected