a fWc7@s`dZddlZejdkZejdkZejdksDdejkr@dkrLnnedejdkZejdZ e ed Z e rej d kred d ej vZddlZeeZerddlZnddlZd dZgdZeZereZddZeefZefZnejZddZefZefZeZ eZ!edj"Z#dj"Z$erdddZ%ddZ&ddZ'ddZ(eZ)Z*ddZ+dd Z,d!d"Z-n@d#dZ%d$dZ&d%dZ'd&dZ(d'd(Z)e$Z*e.Z+d)d Z,d*d"Z-ee%d+ee&d,ee'd-ee(d.ee,d/ee-d0ere/fZ0e/e1fZ2ne/e3fZ0e/e3e1fZ2erZ5e7Z6dd9l?m8Z8m=Z=d:d4Z9d;d6Z:dZ@nd?Z@d@dAZAdBdCZBd[dDdEZCeCZDeredFdGdGdHdIZeEedJZFnedKdLdKdMdIZdNdOZFerdPedQ<ndRedQ<zddSlGmHZHWn$eIy*GdTdUdUeJZHYn0ddVlKmLZLdWdXZMGdYdZdZeLZNeNOeedS)\z7passlib.utils.compat - python 2/3 compatibility helpersN)r))rrz?Passlib requires Python 2.6, 2.7, or >= 3.2 (as of passlib 1.7))rjavapypy_version_info)rrz0passlib requires pypy >= 2.0 (as of passlib 1.7)ZPystoncCs ||_dS)zadd docstring to an objectN)__doc__)objdocr A/usr/lib/python3.9/site-packages/passlib/utils/compat/__init__.pyadd_doc*sr )"PY2PY3PY26BytesIOStringIONativeStringIOSafeConfigParserprint_ int_types num_typesunicode_or_bytes_typesnative_string_typesuunicode uascii_to_str bascii_to_str str_to_uascii str_to_bascii join_unicode join_bytesjoin_byte_valuesjoin_byte_elemsbyte_elem_valueiter_byte_valuesirangeimaplmap iteritems itervaluesnext OrderedDict nullcontextget_method_functionr cCst|tsJ|SN isinstancestrsr r r resrcCst|tsJ|dS)NZunicode_escaper1r2decoder3r r r roscCst|tsJ|Sr/r1rr3r r r rsrcCst|tsJ|dSNascii)r1bytesr6r3r r r rsrcCst|tsJ|Sr/r0r3r r r rsrcCst|tsJ|dSr:)r1r2encoder3r r r rsrcCst|tsJ|Sr/)r1int)elemr r r r$sr$cCst|tsJ|Sr/r1r<r3r r r r%sr%cCst|tsJdd|DS)Ncss|]}t|gVqdSr/)r<.0cr r r r8z"iter_byte_chars..r@r3r r r iter_byte_charssrEcCst|tsJ|dSr:)r1rr=r3r r r rscCst|tsJ|Sr/r@r3r r r rscCst|tsJ|dSr:r5r3r r r rscCst|tsJ|Sr/r0r3r r r rscCstdd|DS)Ncss|]}t|VqdSr/)chr)rBvr r r rDr8z#join_byte_values..)r!valuesr r r r"sr"cCst|tsJdd|DS)Ncss|]}t|VqdSr/)ordrAr r r rDr8z#iter_byte_values..r@r3r r r r%scCst|tsJ|Sr/r@r3r r r rEsz-helper to convert ascii unicode -> native strz+helper to convert ascii bytes -> native strz-helper to convert ascii native str -> unicodez+helper to convert ascii native str -> bytesz2iterate over byte string as sequence of ints 0-255z6iterate over byte string as sequence of 1-byte stringscOstt|i|Sr/)listmap)akr r r r(sr(cCs|Sr/)itemsdr r r r)sr)cCs|Sr/rHrPr r r r*sr*cCs|jSr/)__next__r r r r nextgettersrT)r'izipcCs|Sr/)r)rPr r r r)scCs|Sr/)r*rPr r r r*scCs|jSr/)r+rSr r r rT sz;return function that yields successive values from iterable__func__Zim_funccCs t|t|S)z4given (potential) method, return underlying function)getattrmethod_function_attrfuncr r r r.sr.cCstr|S|jS)z0given unbound method, return underlying function)rrVrYr r r get_unbound_method_function"sr[cCs||_d|_|S)z backward compat hack to suppress exception cause in python3.3+ one python < 3.3 support is dropped, can replace all uses with "raise exc from None" T) __cause____suppress_context__)exccauser r r error_from&sr`z io.BytesIOz io.StringIOzconfigparser.ConfigParser)rZ UnicodeIOrrprintzcStringIO.StringIOzStringIO.StringIOzConfigParser.SafeConfigParserc Os|dtj}|dd}|dd}|r2td|dur>dSt|tpbt|tpbtdd|D}|dur~|rxtdnd}nt|tstd |dur|rtd nd }nt|tstd d }|j }|D]0}|rd }n||t|t st |}||q||dS)zThe new-style print function.filesepNendzinvalid keyword argumentscss|]}t|tVqdSr/r9)rBargr r r rDXr8zprint_.. zend must be None or a string zsep must be None or a stringTF) popsysstdout TypeErrorr1ranyrrwrite basestringr2) argskwdsfprcrdZ want_unicodefirstrmrer r r rIs8      rz.passlib.utils.compat._ordered_dict.OrderedDictr,zcollections.OrderedDict)r-c@s*eZdZdZd ddZddZddZdS) r-zE Context manager that does no additional processing. NcCs ||_dSr/ enter_result)selfrtr r r __init__sznullcontext.__init__cCs|jSr/rs)rur r r __enter__sznullcontext.__enter__cGsdSr/r )ruexc_infor r r __exit__sznullcontext.__exit__)N)__name__ __module__ __qualname__rrvrwryr r r r r-s r-) ModuleTypecCs*|dd\}}t||gdd}t||S)zChelper to import object from module; accept format `path.to.object`.r)fromlistlevel)rsplit __import__rW)sourcemodnameZmodattrmodr r r _import_objectsrc@s>eZdZdZeddZd ddZddZd d Zd d Z dS)_LazyOverlayModuleagproxy module which overlays original module, and lazily imports specified attributes. this is mainly used to prevent importing of resources that are only needed by certain password hashes, yet allow them to be imported from a single location. used by :mod:`passlib.utils`, :mod:`passlib.crypto`, and :mod:`passlib.utils.compat`. cCs$tj|}||||}|tj|<|Sr/)rimodules)clsnameattrmapZorigrur r r replace_modules   z!_LazyOverlayModule.replace_moduleNcCs(t||||_||_t||_dSr/)r}rv_LazyOverlayModule__attrmap_LazyOverlayModule__proxylogging getLogger_LazyOverlayModule__log)rurrproxyr r r rvs z_LazyOverlayModule.__init__cCs~|j}|rt||rt||S|j}||vrl||}t|rD|}nt|}t||||jd|||St d|fdS)Nzloaded lazy attr %r: %rz%'module' object has no attribute '%s') rhasattrrWrcallablersetattrrdebugAttributeError)ruattrrrrvaluer r r __getattr__s  z_LazyOverlayModule.__getattr__cCs |j}|rt|St|SdSr/)rreprr}__repr__)rurr r r rsz_LazyOverlayModule.__repr__cCsJtt|j}||j||j|j}|durB|t|t|Sr/)setdir __class__update__dict__rrrK)ruattrsrr r r __dir__s  z_LazyOverlayModule.__dir__)N) rzr{r|r classmethodrrvrrrr r r r rs   r)N)Prri version_inforr RuntimeErrorrplatform startswithZJYTHONrZPYPYrversionZPYSTONrrrzlogbuiltinsZ __builtin__r __all__dictZ _lazy_attrsr2rrr<rrrnZunicode_or_bytesZunicode_or_strjoinr r!rrrrr"r#r$r%rErJr>rfloatrZlongranger&r(rLr'r)r*rTziprUZxrange itertoolsrXr.r[r`Zsuppress_causerWr contextlibr- ImportErrorobjecttypesr}rrrr r r r s  $     +            -  :