/opt/alt/python37/lib/python3.7/site-packages/beaker/__pycache__
NameSizeModeActions
cache.cpython-37.pyc200000644editdlrm
container.cpython-37.pyc240870644editdlrm
converters.cpython-37.pyc8880644editdlrm
cookie.cpython-37.pyc17790644editdlrm
exceptions.cpython-37.pyc12980644editdlrm
middleware.cpython-37.pyc56490644editdlrm
session.cpython-37.pyc269730644editdlrm
synchronization.cpython-37.pyc106310644editdlrm
util.cpython-37.pyc167830644editdlrm
_compat.cpython-37.pyc42170644editdlrm
__init__.cpython-37.pyc1730644editdlrm
Edit: /opt/alt/python37/lib/python3.7/site-packages/beaker/__pycache__/util.cpython-37.pyc (16783B)
B [B@sdZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z m Z mZy ddlZWnek rtddlZYnXddlmZmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl!m"Z"ddlm#Z$d Z%d d d d dddgZ&ddZ'dAddZ(ddZ)ddZ*ddZ+dBddZ,ddZ-Gdd d e.Z/Gd d d e.Z0Gd!d d e0Z1da2dCd$d Z3d%d&Z4d'd(Z5d)d*Z6d+d,Z7d-d.Z8d/d0Z9dDd1d2Z:d3d4Z;d5d6Zd;dZ?dZAd?d@ZBdS)EzBeaker utilitiesN) PY2 string_type unicode_textNoneType dictkeyslistim_classim_funcpicklefunc_signaturedefault_im_func)datetime timedelta)asbool) exceptions)local ThreadLocalWeakValuedRegistrySyncDict encoded_pathverify_directory serialize deserializecCs ||_|S)zReturn a function with a given __name__. Will assign to __name__ and return the original function if possible on the Python implementation, otherwise a new function will be constructed. )__name__)fnnamer.decorate..maybe)rr)rr')r r%r&)rr$rdecorate7szskip_if..decorate)rnoser )r%r&r(r)r r%r&rskip_if1s   r*cOs<y|||d}Wn|k r*d}YnX|s8tddS)zGAssert the given exception is raised by the given function + arguments.FTz#Callable did not raise an exceptionN)AssertionError)Z except_clsZ callable_r!r"successrrr assert_raisesEs   r-cCsJd}x@t|tjsDy|d7}t|Wq|dkr<YqXqWdS)zcverifies and creates a directory. tries to ignore collisions with other threads and processes.rrN)osaccessF_OKmakedirs)dirZtriesrrrrRscCs*tt|j}|r"|ddkr"dSdSdS)z8Return True if the given function has a 'self' argument.r)selfclsTFN)listr parameters)funcr!rrr has_self_arg`sr9cCs0t|trtj|tj|dntj||ddS)zIssue a warning.) stacklevelN) isinstancerwarningswarnrZ BeakerWarning)r#r;rrrr>is r>csfdd}|S)Ncs*fdd}j|_djf|_|S)Ncsttd||S)N)r=r>DeprecationWarning)r!Zkargs)rmessagerrdeprecated_methodssz6deprecated..wrapper..deprecated_methodz%s %s)r__doc__)rrB)rA)rrwrapperrszdeprecated..wrapperr)rArDr)rAr deprecatedqs rEc@s>eZdZdZdZddZddZddZdd d Zd d Z d S)rz$stores a value on a per-thread basis_tlocalcCs t|_dS)N)rF)r4rrr__init__szThreadLocal.__init__cCs ||j_dS)N)rFvalue)r4rHrrrputszThreadLocal.putcCs t|jdS)NrH)hasattrrF)r4rrrhasszThreadLocal.hasNcCst|jd|S)NrH)getattrrF)r4defaultrrrgetszThreadLocal.getcCs |j`dS)N)rFrH)r4rrrremoveszThreadLocal.remove)N) r __module__ __qualname__rC __slots__rGrIrKrNrOrrrrr}s c@s`eZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ dS)ra An efficient/threadsafe singleton map algorithm, a.k.a. "get a value based on this key, and create if not found or not valid" paradigm: exists && isvalid ? get : create Designed to work with weakref dictionaries to expect items to asynchronously disappear from the dictionary. Use python 2.3.3 or greater ! a major bug was just fixed in Nov. 2003 that was driving me nuts with garbage collection/weakrefs in this section. cCst|_i|_dS)N) _threadingLockmutexdict)r4rrrrGs zSyncDict.__init__cOsVy,||jkr|j|S|j||f||SWn$tk rP|j||f||SXdS)N)rVsync_getKeyError)r4key createfuncr!kwargsrrrrNs   z SyncDict.getcOsr|jzVy,||jkr"|j|S|j||f||SWn$tk r\|j||f||SXWd|jXdS)N)rUacquirerV_createrXrelease)r4rYrZr!r[rrrrWs   zSyncDict.sync_getcOs|||||<}|S)Nr)r4rYrZr!r[objrrrr]szSyncDict._createcCs ||jkS)N)rV)r4rYrrrhas_keyszSyncDict.has_keycCs |j|S)N)rV __contains__)r4rYrrrraszSyncDict.__contains__cCs |j|S)N)rV __getitem__)r4rYrrrrbszSyncDict.__getitem__cCs|j||dS)N)rV __setitem__)r4rYrHrrrrcszSyncDict.__setitem__cCs |j|S)N)rV __delitem__)r4rYrrrrdszSyncDict.__delitem__cCs|jdS)N)rVclear)r4rrrreszSyncDict.clearN)rrPrQrCrGrNrWr]r`rarbrcrdrerrrrrs  c@seZdZddZdS)rcCst|_t|_dS)N)rSRLockrUweakrefWeakValueDictionaryrV)r4rrrrGs zWeakValuedRegistry.__init__N)rrPrQrGrrrrrs.encTc Csd|}tdkrddlma|rLt|tr@t|d}n t|}tj |}g}x$t d|D]}| |d|qhWtjj|f|}t |tj|||S)zsGenerate a unique file-accessible path from the given list of identifiers starting at the given root directory._Nr)sha1zutf-8r) joinrkZ beaker.cryptor<rencode hexdigestr/pathbasenamerangeappendr) rootZ identifiers extensiondepthZdigest_filenamesidenttokensdr3rrrrs     cCs8t|tr|St|tr,td|r,t|StddS)Nz^\d+$zThis is not a proper int)r<intrrematch Exception)r_rrrasints  r}cCst||st|ts|f}d}x|D]}yn|ttfkrLdd|dD}nD|tkrZt}n.|tkrht}n |tt fkrt||st d|||}d}Wn YnX|r$Pq$W|st |nt|t r| st d||S)NFcSsg|] }|qSr)strip).0xrrr sz"verify_options..,z%s requires a timedelta typeTz!Empty strings are invalid for: %s) r<tupler6splitboolrryr}rr r|strr~)opttypeserrorZcoercedtyprrrverify_optionss4         rcCs4x.|D]&\}}}||krt||||||<qW|S)N)r)paramsZrulesetrYrrArrr verify_rulessrcCsPdttfdfdttfdfdttfdfdttttfdfd ttfd fd ttfd fd tfdfdtfdfdttfdfdttfdfdttfdfdttfdfdttfdfdttfdfdttfdfdttfd fd!ttfd"fd#ttfd$fd%tfd&fg}t||}|d}|r&t|tr&t|ts&t|d'|d<|ddk rL|dd(sLt d)|S)*Ndata_dirz3data_dir must be a string referring to a directory.lock_dirz3lock_dir must be a string referring to a directory.typezSession type must be a string.cookie_expireszGCookie expires was not a boolean, datetime, int, or timedelta instance.Z cookie_domainzCookie domain must be a string.Z cookie_pathzCookie path must be a string.idzSession id must be a string.rYzSession key must be a string.Zsecretz Session secret must be a string.Z validate_keyz%Session encrypt_key must be a string.Z encrypt_keyz&Session validate_key must be a string.Zencrypt_nonce_bitsz+Session encrypt_nonce_bits must be a numberZsecurez!Session secure must be a boolean.Zhttponlyz#Session httponly must be a boolean.timeoutz#Session timeout must be an integer.Zsave_accessed_timez@Session save_accessed_time must be a boolean (defaults to true).autozSession is created if accessed.Zwebtest_varnamez!Session varname must be a string.Zdata_serializerz!data_serializer must be a string.)secondsTz.save_accessed_time must be true to use timeout) rrrr rryrrNr<r|)rrulesoptsrrrrcoerce_session_params&s:                    rc Csbdttfdfdttfdfdtfdfdttfdfd ttfd fd tttfd fd ttfdfg}t||S)Nrz3data_dir must be a string referring to a directory.rz3lock_dir must be a string referring to a directory.rzCache type must be a string.enabledz&enabled must be true/false if present.expirezNexpire must be an integer representing how many seconds the cache is valid forregionsz7Regions must be a comma separated list of valid regions key_lengthzUkey_length must be an integer which indicates the longest a key can be before hashing)rrrryr6rr)rrrrrcoerce_cache_paramsJs     rcCs>dttfdfdttfdfdtfdfdtfdfd tfd fd tfd fd ttfdfdtfdfdttfdfdtfdfdttfdfdttfdfdttfdfdttfdfdttfdfdtfd fd!ttfd"fd#tfd$fd%tfd&fd'tfd(fd)ttfd*fd+tfd,fd-tfd.fd/tfd0fd1tfd2fd3tfd4fd5ttfd6fd7tfd8fg}t||S)9NZcasz#cas must be a boolean or an integerZno_blockz(no_block must be a boolean or an integerZreceive_timeoutz"receive_timeout must be an integerZ send_timeoutzsend_timeout must be an integerZ ketama_hashzHketama_hash must be a string designating a valid hashing strategy optionZ _poll_timeoutz _poll_timeout must be an integerZ auto_ejectzauto_eject must be an integerZ retry_timeoutz retry_timeout must be an integerZ _sort_hostsz_sort_hosts must be an integerZ_io_msg_watermarkz$_io_msg_watermark must be an integerZketamaz&ketama must be a boolean or an integerZketama_weightedz/ketama_weighted must be a boolean or an integerZ_io_key_prefetchz0_io_key_prefetch must be a boolean or an integerZ_hash_with_prefix_keyz5_hash_with_prefix_key must be a boolean or an integerZ tcp_nodelayz+tcp_nodelay must be a boolean or an integerZ failure_limitz failure_limit must be an integerZbuffer_requestsz/buffer_requests must be a boolean or an integerZ_socket_send_sizez$_socket_send_size must be an integerZ num_replicasznum_replicas must be an integerZ remove_failedz remove_failed must be an integerZ_noreplyz(_noreply must be a boolean or an integerZ_io_bytes_watermarkz&_io_bytes_watermark must be an integerZ_socket_recv_sizez$_socket_recv_size must be an integer distributionzEdistribution must be a string designating a valid distribution optionZconnect_timeoutz"connect_timeout must be an integerhashz8hash must be a string designating a valid hashing optionZ verify_keysz+verify_keys must be a boolean or an integerZ dead_timeoutzdead_timeout must be an integer)rryrr) behaviorsrrrrcoerce_memcached_behaviorsZs@                        rc Cs@|rtddddd}ni}xH|D]<\}}|drF|||dd<|dr$|||dd<q$Wt|d|kr|rd |d<|d d}|rrEobjectrrrrkrr}rrrrrrrrrrrrrrrrrrsl0        A  $% .