^]L_ X d Z ddgZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ej d Z ej d
Z
ej d Z ej d
Z ej d Zd
ZdZ e Z G d de Z G d d Z G d de ZdS )a 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.
FeedParserBytesFeedParser N)errors)compat32)deque)StringIOz
\r\n|\r|\nz(\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])
c N e Zd ZdZd Zd Zd Zd Zd Zd Z d Z
d Zd
Zd Z
dS )
BufferedSubFileak 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.
c r t d | _ t | _ g | _ d| _ d S )Nr )newlineF)r _partialr _lines _eofstack_closedselfs 7/opt/alt/python311/lib64/python3.11/email/feedparser.py__init__zBufferedSubFile.__init__4 s3 !,,,
gg c : | j | d S N)r append)r preds r push_eof_matcherz BufferedSubFile.push_eof_matcher? s d#####r c 4 | j S r )r popr s r pop_eof_matcherzBufferedSubFile.pop_eof_matcherB s ~!!###r c | j d | | j | j d | j d| _ d S )Nr T)r seek pushlines readlinestruncater r s r closezBufferedSubFile.closeE sm
1t}..00111
1
r c | j s| j rdS t S | j }t | j D ]*} || r| j | dS +|S Nr )r r NeedMoreDatapopleftreversedr
appendleft)r lineateofs r readlinezBufferedSubFile.readlineM s { |
r {""$$ dn-- EuT{{
&&t,,,rr
r c : | j | d S r )r r+ r r, s r
unreadlinezBufferedSubFile.unreadline_ s
t$$$$$r c | j | d|vrd|vrdS | j d | j }| j d | j |d d s,| j | | | dS )z$Push some new data into this object.r
Nr )r writer! r# r$ endswithr r" )r datapartss r pushzBufferedSubFile.pushd s
D!!!tD 0 0F
1
''))
1
Ry!!$'' -M ,,,ur c : | j | d S r )r extend)r liness r r" zBufferedSubFile.pushlinesy s 5!!!!!r c | S r r s r __iter__zBufferedSubFile.__iter__| s r c H | }|dk rt |S r' )r.
StopIterationr0 s r __next__zBufferedSubFile.__next__ s# }}2::r N)__name__
__module____qualname____doc__r r r r% r. r1 r9 r" r? rB r> r r r r , s $ $ $$ $ $ $% % %
*" " " r r c P e Zd ZdZd
eddZd Zd Zd Zd Z d Z
d
Zd Zd Z
dS )r zA feed-style parser of email.Npolicyc f || _ d| _ |"|j ddlm} || _ n>|j | _ n1|| _ || j n# t $ r
d| _ Y nw xY wt | _ g | _ |
j | _ d| _
d| _ d| _ dS )a _factory is called with no arguments to create a new message obj
The policy keyword specifies a policy object that controls a number of
aspects of the parser's operation. The default policy maintains
backward compatibility.
FNr )MessagerH T)rI _old_style_factorymessage_factory
email.messagerK _factory TypeErrorr _input _msgstack _parsegenrB _parse_cur_last_headersonly)r rO rI rK s r r zFeedParser.__init__ s "'%-111111 '
& 6
$DM
/,,,,,
/
/
/*.'''
/ &''nn&&/
!s A
A! A!c d| _ d S )NT)rW r s r _set_headersonlyzFeedParser._set_headersonly s r c b | j | | dS )zPush more data into the parser.N)rQ r9 _call_parse)r r7 s r feedzFeedParser.feed s0 r c R | d S # t $ r Y d S w xY wr )rT rA r s r r[ zFeedParser._call_parse s: KKMMMMM DD s
&&c J | j | | }| dk rI| s5| j s.t j }| j
|| |S )z