mς mγΈEc@s°dZdkZdkZdkZdkZdklZlZlZl Z l Z dk l Z l Z dklZlZlZeidƒiZd„Zdefd„ƒYZdS( sΝLoad / save to libwww-perl (LWP) format files. Actually, the format is slightly extended from that used by LWP's (libwww-perl's) HTTP::Cookies, to avoid losing some RFC 2965 information not recorded by LWP. It uses the version string "2.0", though really there isn't an LWP Cookies 2.0 format. This indicates that there is extra information in here (domain_dot and port_spec) while still being compatible with libwww-perl, I hope. Copyright 2002-2006 John J Lee Copyright 1997-1999 Gisle Aas (original libwww-perl code) This code is free software; you can redistribute it and/or modify it under the terms of the BSD or ZPL 2.1 licenses (see the file COPYING.txt included with the distribution). N(sreraise_unmasked_exceptionss FileCookieJarsCookiesMISSING_FILENAME_TEXTs LoadError(sjoin_header_wordsssplit_header_words(s startswithsiso2times time2isozt mechanizecCsγ|i|ifd|ifd|ifg}|idj o|id|ifƒn|i o|idƒn|i o|idƒn|i o|idƒn|i o|idƒn|i o&|idtt|i ƒƒfƒn|io|idƒn|io|id |ifƒn|io|id |ifƒn|io|idƒn|iƒ}|iƒx0|D](}|i|t|i|ƒƒfƒqŽW|id t|iƒfƒt|gƒS(s“Return string representation of Cookie in an the LWP cookie file format. Actually, the format is extended a bit -- see module docstring. tpathtdomaintportt path_spect port_spect domain_dottsecuretexpirestdiscardtcommentt commenturltrfc2109tversionN(RN(RN(RN(ssecureN(sdiscardN(srfc2109N(tcookietnametvalueRRthRtNonetappendtpath_specifiedtport_specifiedtdomain_initial_dotRRt time2isoztfloatR R t comment_urlR tnonstandard_attr_keystkeystsorttktstrtget_nonstandard_attrR tjoin_header_words(RRRR((t6/data/zmath/zope/lib/python/mechanize/_lwpcookiejar.pytlwp_cookie_strs:-     &      &t LWPCookieJarcBs>tZdZdZeed„Zeeed„Zd„Z RS(sY The LWPCookieJar saves a sequence of"Set-Cookie3" lines. "Set-Cookie3" is the format used by the libwww-perl libary, not known to be compatible with any browser, but which is easy to read and doesn't lose information about RFC 2965 cookies. Additional methods as_lwp_str(ignore_discard=True, ignore_expired=True) s^\#LWP-Cookies-(\d+\.\d+)cCs©tiƒ}g}x}|D]u}| o!|iotd|iƒqn| o'|i |ƒotd|iƒqn|i dt |ƒƒqWt i|dgdƒS(sReturn cookies as a string of " "-separated "Set-Cookie3" headers. ignore_discard and ignore_expires: see docstring for FileCookieJar.save s$ Not saving %s: marked for discards Not saving %s: expiredsSet-Cookie3: %sts N(ttimetnowtrtselfRtignore_discardR tdebugRtignore_expirest is_expiredRR"tstringtjoin(R(R)R+R'RR&((R!t as_lwp_strLs cCs|djo-|idj o |i}q:ttƒ‚nt|dƒ}z4tdƒ|idƒ|i|i ||ƒƒWd|i ƒXdS(NtwsSaving LWP cookies files#LWP-Cookies-2.0 ( tfilenameRR(t ValueErrortMISSING_FILENAME_TEXTtopentfR*twriteR/R)R+tclose(R(R1R)R+R5((R!tsave^s    cCs|iƒ}ti|i|ƒpd|} t | ƒ‚nt i ƒ}d}d}d}y”x|iƒ}|djoPnt||ƒpq`nti|t|ƒƒ}x7t|gƒD]&}|d\}}h} h}x|D]}t| |RPR/RRLR8RY(((R!R#=s (R\R%R<R-tloggingt _clientcookieRWt FileCookieJarRTR3R@t _headersutilR RHt_utilRERRRt getLoggerR*R"R#(RER]R-R_R3R"RRR@RHR<RTR%R*RWRR#R ((R!t?s$%