💾 Archived View for tris.fyi › pydoc › email.feedparser captured on 2023-01-29 at 04:13:14. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-07-16)

🚧 View Differences

-=-=-=-=-=-=-

Back to module index

Go to module by name

email

email.feedparser

FeedParser - An email feed parser.

The feed parser implements an interface for incrementally parsing an email
message, line by line.  This has advantages for certain applications, such as
those reading email messages off a socket.

FeedParser.feed() is the primary interface for pushing new data into the
parser.  It returns when there's nothing more it can do with the available
data.  When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.

The other advantage of this parser is that it will never raise a parsing
exception.  Instead, when it finds something unexpected, it adds a 'defect' to
the current message.  Defects are just instances that live on the message
object's .defects attribute.

Classes

BufferedSubFile

A file-ish object that can have new data loaded into it.

    You can also push and pop line-matching predicates onto a stack.  When the
    current predicate matches the current line, a false EOF response
    (i.e. empty string) is returned instead.  This lets the parser adhere to a
    simple abstraction -- it parses until EOF closes the current message.
    
close(self)
pop_eof_matcher(self)
push(self, data)

  Push some new data into this object.
push_eof_matcher(self, pred)
pushlines(self, lines)
readline(self)
unreadline(self, line)

BytesFeedParser

Like FeedParser, but feed accepts bytes.
close(self)

  Parse all remaining data and return the root message object.
feed(self, data)

FeedParser

A feed-style parser of email.
close(self)

  Parse all remaining data and return the root message object.
feed(self, data)

  Push more data into the parser.

StringIO

Text I/O implementation using an in-memory buffer.

The initial_value argument sets the value of object.  The newline
argument is like the one of TextIOWrapper's constructor.
close(self, /)

  Close the IO object.

  Attempting any further operation after the object is closed
  will raise a ValueError.

  This method has no effect if the file is already closed.
detach(...)

  Separate the underlying buffer from the TextIOBase and return it.

  After the underlying buffer has been detached, the TextIO is in an
  unusable state.

fileno(self, /)

  Returns underlying file descriptor if one exists.

  OSError is raised if the IO object does not use a file descriptor.
flush(self, /)

  Flush write buffers, if applicable.

  This is not implemented for read-only and non-blocking streams.
getvalue(self, /)

  Retrieve the entire contents of the object.
isatty(self, /)

  Return whether this is an 'interactive' stream.

  Return False if it can't be determined.
read(self, size=-1, /)

  Read at most size characters, returned as a string.

  If the argument is negative or omitted, read until EOF
  is reached. Return an empty string at EOF.
readable(self, /)

  Returns True if the IO object can be read.
readline(self, size=-1, /)

  Read until newline or EOF.

  Returns an empty string if EOF is hit immediately.
readlines(self, hint=-1, /)

  Return a list of lines from the stream.

  hint can be specified to control the number of lines read: no more
  lines will be read if the total size (in bytes/characters) of all
  lines so far exceeds hint.
seek(self, pos, whence=0, /)

  Change stream position.

  Seek to character offset pos relative to position indicated by whence:
      0  Start of stream (the default).  pos should be >= 0;
      1  Current position - pos must be 0;
      2  End of stream - pos must be 0.
  Returns the new absolute position.
seekable(self, /)

  Returns True if the IO object can be seeked.
tell(self, /)

  Tell the current file position.
truncate(self, pos=None, /)

  Truncate size to pos.

  The pos argument defaults to the current file position, as
  returned by tell().  The current file position is unchanged.
  Returns the new absolute position.
writable(self, /)

  Returns True if the IO object can be written.
write(self, s, /)

  Write string to file.

  Returns the number of characters written, which is always equal to
  the length of the string.
writelines(self, lines, /)

  Write a list of lines to stream.

  Line separators are not added, so it is usual for each of the
  lines provided to have a line separator at the end.
closed = <attribute 'closed' of '_io.StringIO' objects>
encoding = <attribute 'encoding' of '_io._TextIOBase' objects>
  Encoding of the text stream.

  Subclasses should override.

errors = <attribute 'errors' of '_io._TextIOBase' objects>
  The error setting of the decoder or encoder.

  Subclasses should override.

line_buffering = <attribute 'line_buffering' of '_io.StringIO' objects>
newlines = <attribute 'newlines' of '_io.StringIO' objects>

deque

deque([iterable[, maxlen]]) --> deque object

A list-like sequence optimized for data accesses near its endpoints.
append(...)

  Add an element to the right side of the deque.
appendleft(...)

  Add an element to the left side of the deque.
clear(...)

  Remove all elements from the deque.
copy(...)

  Return a shallow copy of a deque.
count(...)

  D.count(value) -> integer -- return number of occurrences of value
extend(...)

  Extend the right side of the deque with elements from the iterable
extendleft(...)

  Extend the left side of the deque with elements from the iterable
index(...)

  D.index(value, [start, [stop]]) -> integer -- return first index of value.
  Raises ValueError if the value is not present.
insert(...)

  D.insert(index, object) -- insert object before index
pop(...)

  Remove and return the rightmost element.
popleft(...)

  Remove and return the leftmost element.
remove(...)

  D.remove(value) -- remove first occurrence of value.
reverse(...)

  D.reverse() -- reverse *IN PLACE*
rotate(...)

  Rotate the deque n steps to the right (default n=1).  If n is negative, rotates left.
maxlen = <attribute 'maxlen' of 'collections.deque' objects>
  maximum size of a deque or None if unbounded

Other members

EMPTYSTRING = ''
NL = '\n'
NLCRE = re.compile('\\r\\n|\\r|\\n')
NLCRE_bol = re.compile('(\\r\\n|\\r|\\n)')
NLCRE_crack = re.compile('(\\r\\n|\\r|\\n)')
NLCRE_eol = re.compile('(\\r\\n|\\r|\\n)\\Z')
NeedMoreData = <object object at 0x7f75e3c95730>
compat32 = Compat32()
headerRE = re.compile('^(From |[\\041-\\071\\073-\\176]*:|[\\t ])')

Modules

errors

re