mò mã¸Ec@s²dZdkZdkZdkZdkZdklZlZdkl Z ye Wn%e j odk Z e i Z nXd„Zd„Zd„Zdeifd„ƒYZdS( s0Integration with Python standard library module urllib2: OpenerDirector class. Copyright 2004-2006 John J Lee 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(s startswiths isstringlike(sRequestcCst|ƒiƒS(sjReturn method names of class instance. dir(obj) doesn't work across Python versions, this does. N(tmethnames_of_instance_as_dicttobjtkeys(R((t0/data/zmath/zope/lib/python/mechanize/_opener.pyt methnamesscCs~h}|it|iƒƒx[t|ƒD]M}yt||ƒ}Wnt j o q)nXt |ƒod||>> class BadAttr(object): ... def error(self): ... raise AttributeError ... error = property(error) >>> inst = BadAttr() >>> 'error' in dir(inst) True >>> inst.error Traceback (most recent call last): ... AttributeError >>> result = methnames_of_instance_as_dict(inst) # no exception N( tnamestupdatetmethnames_of_class_as_dicttinstt __class__tdirtmethnametgetattrt candidatetAttributeErrortcallabletNone(RR R R((RRs  cCsh}x[t|ƒD]M}yt||ƒ}Wntj o qnXt|ƒod||>> class BadClass(object): ... def error(self): ... raise AttributeError ... error = property(error) ... __bases__ = [] >>> klass = BadClass() >>> 'error' in dir(klass) True >>> klass.error Traceback (most recent call last): ... AttributeError >>> result = methnames_of_class_as_dict(klass) # no exception N( RR tklassR R R RRRt __bases__t baseclassRR(RR R RR((RR?s   tOpenerDirectorcBsStZd„Zd„Zd„Zd„Zdd„Zd„Zdddd„Z RS(NcCsAtii|ƒh|_h|_h|_h|_t|_ dS(N( turllib2Rt__init__tselftprocess_responsetprocess_requestt _any_requestt _any_responsetTruet_handler_index_valid(R((RRcs     cCsE||ijodSnti|i|ƒ|i|ƒt|_dS(N(thandlerRthandlerstbisecttinsortt add_parenttFalseR(RR((Rt add_handlerms  cCsE|iodSnh}h}h}h} tƒ}tƒ}g} xÐ|i D]Å} t }xžt| ƒD]}|dddgjoqen|djo|i| ƒt}qen(|djo|i| ƒt}qen|idƒ}|| } ||d}t|dƒolti||ddƒ|d}||d}yt|ƒ}Wntj onX|i| hƒ} n[|d jo| }|} n>|d jo| }|} n!|d jo| }| } nqe| i|tƒƒi| ƒt}qeW|p| i| ƒqLqLWx| D]} |i i| ƒqWx;|| gD]-} x$| i ƒD]\} }|| | tblocktlentwritetclosetIOError(RRRRoR~RLR}RjRgR{RMRlR|RzRuRsRnRkR€((RtretrievesN       ( t__name__t __module__RR$RHRORR,R+R…(((RRbs  T & (t__doc__RR;R Rtt_utilR:RIRORKR1t NameErrortsetstSetRRRR( R:R1RR;R RIR‹RKRRtRRR((Rt? s$    #