ó zfc@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|ƒ‚nyxz|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|jrqPn| r¹|j|ƒr¹qPn|j|ƒqPWWnAtk rá‚n.tk rtƒ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_specifiedtpathtsecuretexpirestnametvaluet initial_dotRtc((s)/usr/lib64/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}|j j dƒrÖd}nd}|j dk rýt|j ƒ} nd} |jdkr$d} |j} n|j} |j} |jdj|j ||j|| | | gƒdƒqkWWd|jƒXdS(NtwR tFALSER Rs s (RR t ValueErrorRtopentwritetheaderR RRR)R&RR*tstrR,R+tjoinR(R( RR R!R"RR#tcookieR)R-R*R+R,((s)/usr/lib64/python2.7/_MozillaCookieJar.pytsaveqs@         N( t__name__t __module__t__doc__RR5R/RRR9(((s)/usr/lib64/python2.7/_MozillaCookieJar.pyRs  B( R<R R t cookielibRRRRRR(((s)/usr/lib64/python2.7/_MozillaCookieJar.pyts(