ó lSþLc@s9dZddlZddlZddlmZddlTddlmZddl m Z ddl m Z ddl m Z dd lmZdd lmZyddlZWnddlZnXeeƒZd dd „ƒYZd efd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(s! Contains basic caching classes. iÿÿÿÿN(t gettempdir(t*(tParser(tElement(tdatetime(t timedelta(tStringIO(t getLoggertCachecBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s! An object object cache. cCstdƒ‚dS(s§ Get a object from the cache by ID. @param id: The object ID. @type id: str @return: The object, else None @rtype: any snot-implementedN(t Exception(tselftid((s./usr/lib/python2.7/site-packages/suds/cache.pytget,scCstdƒ‚dS(s§ Get a object from the cache by ID. @param id: The object ID. @type id: str @return: The object, else None @rtype: any snot-implementedN(R (R R ((s./usr/lib/python2.7/site-packages/suds/cache.pytgetf6scCstdƒ‚dS(sª Put a object into the cache. @param id: The object ID. @type id: str @param object: The object to add. @type object: any snot-implementedN(R (R R tobject((s./usr/lib/python2.7/site-packages/suds/cache.pytput@scCstdƒ‚dS(s© Write a fp into the cache. @param id: The object ID. @type id: str @param fp: File pointer. @type fp: file-like object. snot-implementedN(R (R R tfp((s./usr/lib/python2.7/site-packages/suds/cache.pytputfJscCstdƒ‚dS(st Purge a object from the cache by id. @param id: A object ID. @type id: str snot-implementedN(R (R R ((s./usr/lib/python2.7/site-packages/suds/cache.pytpurgeTscCstdƒ‚dS(s3 Clear all objects from the cache. snot-implementedN(R (R ((s./usr/lib/python2.7/site-packages/suds/cache.pytclear\s( t__name__t __module__t__doc__R R RRRR(((s./usr/lib/python2.7/site-packages/suds/cache.pyR's tNoCachecBs2eZdZd„Zd„Zd„Zd„ZRS(s$ The passthru object cache. cCsdS(N(tNone(R R ((s./usr/lib/python2.7/site-packages/suds/cache.pyR hscCsdS(N(R(R R ((s./usr/lib/python2.7/site-packages/suds/cache.pyR kscCsdS(N((R R R((s./usr/lib/python2.7/site-packages/suds/cache.pyRnscCsdS(N((R R R((s./usr/lib/python2.7/site-packages/suds/cache.pyRqs(RRRR R RR(((s./usr/lib/python2.7/site-packages/suds/cache.pyRcs    t FileCachecBs¤eZdZdZdZdd„Zd „Zd „Zd „Z d „Z d „Z d„Z d„Z d„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s: A file-based URL cache. @cvar fnprefix: The file name prefix. @type fnsuffix: str @ivar duration: The cached file duration which defines how long the file will be cached. @type duration: (unit, value) @ivar location: The directory for the cached files. @type location: str tsudstmonthstweekstdaysthourstminutestsecondscKsT|dkr'tjjtƒdƒ}n||_d|_|j||jƒdS(s^ @param location: The directory for the cached files. @type location: str @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. The duration may be: (months|weeks|days|hours|minutes|seconds). @type duration: {unit:value} RiN(Ni( Rtostpathtjointtmptlocationtdurationt setdurationt checkversion(R R%R&((s./usr/lib/python2.7/site-packages/suds/cache.pyt__init__ƒs    cCsdS(sZ Get the file name suffix @return: The suffix @rtype: str tgcf((R ((s./usr/lib/python2.7/site-packages/suds/cache.pytfnsuffix“scKsat|ƒdkr]|jƒd}|d|jkrQtdt|jƒƒ‚n||_n|S(s_ Set the caching duration which defines how long the file will be cached. @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. The duration may be: (months|weeks|days|hours|minutes|seconds). @type duration: {unit:value} iis must be: %s(tlentitemstunitsR tstrR&(R R&targ((s./usr/lib/python2.7/site-packages/suds/cache.pyR'›s  cCs ||_dS(s Set the location (directory) for the cached files. @param location: The directory for the cached files. @type location: str N(R%(R R%((s./usr/lib/python2.7/site-packages/suds/cache.pyt setlocation«scCsPy,tjj|jƒs+tj|jƒnWntj|jddƒnX|S(sM Make the I{location} directory if it doesn't already exits. texc_infoi(R!R"tisdirR%tmakedirstlogtdebug(R ((s./usr/lib/python2.7/site-packages/suds/cache.pytmktmp³s cCsby@|j|ƒ}|j|dƒ}|j|ƒ|jƒ|SWntj|ddƒ|SXdS(NtwR2i(t_FileCache__fntopentwritetcloseR5R6(R R tbfrtfntf((s./usr/lib/python2.7/site-packages/suds/cache.pyR¾s  cCsxyV|j|ƒ}|j|dƒ}|j|jƒƒ|jƒ|jƒt|ƒSWntj|ddƒ|SXdS(NR8R2i(R9R:R;treadR<R5R6(R R RR>R?((s./usr/lib/python2.7/site-packages/suds/cache.pyRÉs  cCs;y-|j|ƒ}|jƒ}|jƒ|SWnnXdS(N(R R@R<(R R R?R=((s./usr/lib/python2.7/site-packages/suds/cache.pyR Õs  cCs;y-|j|ƒ}|j|ƒ|j|ƒSWnnXdS(N(R9tvalidateR:(R R R>((s./usr/lib/python2.7/site-packages/suds/cache.pyR Þs  cCs“|jddkrdStjtjj|ƒƒ}i|jd|jd6}|t|}|tjƒkrtj d|ƒtj |ƒndS(sŠ Validate that the file has not expired based on the I{duration}. @param fn: The file name. @type fn: str iNis%s expired, deleted( R&tdtt fromtimestampR!R"tgetctimeRtnowR5R6tremove(R R>tcreatedtdtexpired((s./usr/lib/python2.7/site-packages/suds/cache.pyRAæscCsƒx|tj|jƒD]h}tjj|j|ƒ}tjj|ƒrIqn|j|jƒrtj|ƒt j d|ƒqqWdS(Ns deleted: %s( R!tlistdirR%R"R#R3t startswithtfnprefixRFR5R6(R R>R"((s./usr/lib/python2.7/site-packages/suds/cache.pyRõs cCs.|j|ƒ}ytj|ƒWnnXdS(N(R9R!RF(R R R>((s./usr/lib/python2.7/site-packages/suds/cache.pyRþs cGs|jƒt||ŒS(sK Open the cache file making sure the directory is created. (R7R:(R R>targs((s./usr/lib/python2.7/site-packages/suds/cache.pyR:s cCs tjj|jdƒ}yD|j|ƒ}|jƒ}|jƒ|tjkr[t ƒ‚nWn=|j ƒ|j|dƒ}|j tjƒ|jƒnXdS(NtversionR8( R!R"R#R%R:R@R<Rt __version__R RR;(R R"R?RN((s./usr/lib/python2.7/site-packages/suds/cache.pyR( s   cCs>|}|jƒ}d|j||f}tjj|j|ƒS(Ns%s-%s.%s(R+RLR!R"R#R%(R R tnametsuffixR>((s./usr/lib/python2.7/site-packages/suds/cache.pyt__fns (RRRRRR N(RRRRLR.RR)R+R'R1R7RRR R RARRR:R(R9(((s./usr/lib/python2.7/site-packages/suds/cache.pyRus$          t DocumentCachecBs)eZdZd„Zd„Zd„ZRS(s( Provides xml document caching. cCsdS(Ntxml((R ((s./usr/lib/python2.7/site-packages/suds/cache.pyR+'scCsZy<tj||ƒ}|dkr%dStƒ}|j|ƒSWntj||ƒnXdS(N(RR RRtparseR(R R Rtp((s./usr/lib/python2.7/site-packages/suds/cache.pyR *s  cCs/t|tƒr+tj||t|ƒƒn|S(N(t isinstanceRRRR/(R R R((s./usr/lib/python2.7/site-packages/suds/cache.pyR4s(RRRR+R R(((s./usr/lib/python2.7/site-packages/suds/cache.pyRS"s  t ObjectCachecBs/eZdZdZd„Zd„Zd„ZRS(sm Provides pickled object caching. @cvar protocol: The pickling protocol. @type protocol: int icCsdS(Ntpx((R ((s./usr/lib/python2.7/site-packages/suds/cache.pyR+BscCsQy3tj||ƒ}|dkr%dStj|ƒSWntj||ƒnXdS(N(RR RtpickletloadR(R R R((s./usr/lib/python2.7/site-packages/suds/cache.pyR Es cCs,tj||jƒ}tj|||ƒ|S(N(RZtdumpstprotocolRR(R R RR=((s./usr/lib/python2.7/site-packages/suds/cache.pyROs(RRRR]R+R R(((s./usr/lib/python2.7/site-packages/suds/cache.pyRX:s   ((RR!RttempfileRR$tsuds.transporttsuds.sax.parserRtsuds.sax.elementRRRBRt cStringIORtloggingRtcPickleRZRR5RRRRSRX(((s./usr/lib/python2.7/site-packages/suds/cache.pyts(    <­