�`^c@s`dZddlZddlZddlmZmZmZmZmZdefd��YZ dS(s+Mozilla / Netscape cookie loading / saving.i�N(t_warn_unhandled_exceptiont
FileCookieJart LoadErrortCookietMISSING_FILENAME_TEXTtMozillaCookieJarcBs5eZdZdZdZd�Zdeed�ZRS(s�
WARNING: you may want to backup your browser's cookies file if you use
this class to save cookies. I *think* it works, but there have been
bugs in the past!
This class differs from CookieJar only in the format it uses to save and
load cookies to and from a file. This class uses the Mozilla/Netscape
`cookies.txt' format. lynx uses this file format, too.
Don't expect cookies saved while the browser is running to be noticed by
the browser (in fact, Mozilla on unix will overwrite your saved cookies if
you change them on disk while it's running; on Windows, you probably can't
save at all while the browser is running).
Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
Netscape cookies on saving.
In particular, the cookie version and port number information is lost,
together with information about whether or not Path, Port and Discard were
specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
domain as set in the HTTP header started with a dot (yes, I'm aware some
domains in Netscape files start with a dot and some don't -- trust me, you
really don't want to know any more about this).
Note that though Mozilla and Netscape use the same format, they use
slightly different headers. The class saves cookies using the Netscape
header by default (Mozilla can cope with that).
s#( Netscape)? HTTP Cookie Filesr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file! Do not edit.
cCstj�}|j�}tj|j|�sJ|j�td|��ny�xy|j�}|dkrlPn|jd�r�|d }n|j�j d�sP|j�dkr�qPn|j
d�\}} }
}}}
}|dk}| dk} |
dkr|}
d}n|j d �}| |ks-t�t
}|dkrNd}t}ntd
|
|dt
|| ||
t
|||ddi�}|r�|jr�qPn|r�|j|�r�qPn|j|�qPWnAtk
r��n.tk
r
t�td||f��nXdS(
Ns4%r does not look like a Netscape format cookies filets
i�t#t$s tTRUEt.is+invalid Netscape format cookies file %r: %r(RR(ttimetreadlinetretsearchtmagic_retcloseRtendswithtstript
startswithtsplittNonetAssertionErrortFalsetTrueRtdiscardt
is_expiredt
set_cookietIOErrort ExceptionR(tselftftfilenametignore_discardtignore_expirestnowtmagictlinetdomaintdomain_specifiedtpathtsecuretexpirestnametvaluetinitial_dotRtc((s'/sys/lib/python2.7/_MozillaCookieJar.pyt_really_load/sd
$
c
Cs�|dkr6|jdk r'|j}q6tt��nt|d�}z+|j|j�tj�}x|D]}|r�|jr�qkn|r�|j |�r�qkn|j
r�d}nd}|jjd�r�d}nd}|j
dk r�|j
�} nd} |jdkr$d}
|j}n|j}
|j}|jdj|j||j|| |
|g�d�qkWWd|j�XdS(NtwR tFALSER
Rs s
(RR t
ValueErrorRtopentwritetheaderRRRR)R&RR*tstrR,R+tjoinR(R(RR R!R"RR#tcookieR)R-R*R+R,((s'/sys/lib/python2.7/_MozillaCookieJar.pytsaveqs@
N( t__name__t
__module__t__doc__RR5R/RRR9(((s'/sys/lib/python2.7/_MozillaCookieJar.pyRs
B(
R<R
Rt cookielibRRRRRR(((s'/sys/lib/python2.7/_MozillaCookieJar.pyt<module>s(
|