mò mã¸Ec@sŽdZdkZdkZdkZdkZdklZlZlZl Z l Z dk l Z l Z eidƒiZdefd„ƒYZdS(sGMozilla / Netscape cookie loading / saving. 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(s startswithsendswitht ClientCookietMozillaCookieJarcBs5tZdZdZdZd„Zeeed„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 FilesŠ # Netscape HTTP Cookie File # http://www.netscape.com/newsref/std/cookie_spec.html # This is a generated file! Do not edit. cCs4tiƒ} |iƒ} ti|i| ƒp|i ƒt d|ƒ‚ny·x°|iƒ} | djoPnt | dƒo| d } ntti| ƒdƒp/tti| ƒdƒpti| ƒdjoqRnti| dƒ\}}} }}}}|d j}|d j}|djo|}d}nt|d ƒ}||jpt‚t}|djod}t}ntd ||dt|||| t|||ddhƒ} | o| ioqRn| o| i#| ƒoqRn|i$| ƒqRWWn*t%t&fƒt d || fƒ‚nXdS( Ns4%s does not look like a Netscape format cookies fileits iÿÿÿÿt#t$s tTRUEt.is#invalid Netscape format file %s: %s('ttimetnowtftreadlinetmagictretsearchtselftmagic_retcloset LoadErrortfilenametlinetendswitht startswithtstringtstriptsplittdomaintdomain_specifiedtpathtsecuretexpirestnametvaluetNonet initial_dottAssertionErrortFalsetdiscardtTruetCookietctignore_discardtignore_expirest is_expiredt set_cookietreraise_unmasked_exceptionstIOError(RR RR(R)RRRRRRRR'R RRR!R$((t:/data/zmath/zope/lib/python/mechanize/_mozillacookiejar.pyt _really_load;sZ     H'          c CsÁ|djo-|idj o |i}q:ttƒ‚nt|dƒ}zftdƒ|i|i ƒt i ƒ} x9|D]1}| o!|iotd|iƒqyn| o'|i| ƒotd|iƒqyn|io d}nd}t|idƒo d} nd} |idj ot|iƒ}nd}|idjod} |i}n|i} |i}|iti|i| |i||| |gd ƒd ƒqyWWd|iƒXdS( Ntws Saving Netscape cookies.txt files$ Not saving %s: marked for discards Not saving %s: expiredRtFALSERRs s (RR Rt ValueErrortMISSING_FILENAME_TEXTtopenR tdebugtwritetheaderRRtcookieR(R$RR)R*RRRR!RtstrRRtjoinRR( RRR(R)R RRRR8R!RR((R.tsaveysF         *( t__name__t __module__t__doc__RR7R/R R#R;(((R.Rs  >(R>R RRtloggingt _clientcookieR,t FileCookieJarR&R3Rt_utilRRt getLoggerR5R( RR?RRAR3RRR RR&RR5R,((R.t? s $%