Uv6'WdZddlmZddlmZmZmZmZddlm Z m Z ddl m Z er e ZddlmZnddlmZGddeZGd d eeeZd gZd S) a This module redefines ``str`` on Python 2.x to be a subclass of the Py2 ``unicode`` type that behaves like the Python 3.x ``str``. The main differences between ``newstr`` and Python 2.x's ``unicode`` type are the stricter type-checking and absence of a `u''` prefix in the representation. It is designed to be used together with the ``unicode_literals`` import as follows: >>> from __future__ import unicode_literals >>> from builtins import str, isinstance On Python 3.x and normally on Python 2.x, these expressions hold >>> str('blah') is 'blah' True >>> isinstance('blah', str) True However, on Python 2.x, with this import: >>> from __future__ import unicode_literals the same expressions are False: >>> str('blah') is 'blah' False >>> isinstance('blah', str) False This module is designed to be imported together with ``unicode_literals`` on Python 2 to bring the meaning of ``str`` back into alignment with unprefixed string literals (i.e. ``unicode`` subclasses). Note that ``str()`` (and ``print()``) would then normally call the ``__unicode__`` method on objects in Python 2. To define string representations of your objects portably across Py3 and Py2, use the :func:`python_2_unicode_compatible` decorator in :mod:`future.utils`. )Number)PY3istextwith_metaclass isnewbytes)noissubset) newobject)IterableceZdZdZdS) BaseNewStrcl|tkrt|tSt|j|SN)newstr isinstanceunicode issubclass __class__)clsinstances e/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/future/types/newstr.py__instancecheck__zBaseNewStr.__instancecheck__;s. &==h00 0h0#66 6N)__name__ __module__ __qualname__rrrr r :s#77777rr c"eZdZdZdZfdZfdZfdZdZe dfdZ e dd Z fd Z fd Z fd Ze dfd Ze dfdZe ddfdZdZd0fd Ze ddfdZe ddfdZe ddd1fd Ze ddd1fd Ze ddfdZe ddfdZe dddZd2fd Zfd!Zfd"Zfd#Zd$Zfd%Z fd&Z!fd'Z"fd(Z#fd)Z$d*Z%e&d3d+Z'd,Z(d-Z)d.Z*d/Z+xZ,S)4rz6 A backport of the Python 3 str object to Py2 z,Can't convert '{0}' object to str implicitlycXt|dkr(tt||St |dtkr|tkr|dSt |dt r |d}nqt |dtrNd|vst|dkr|dj|ddi|}n#|d }n|d}tt|||S)a/ From the Py3 str docstring: str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'. rencodingN) lensuperr__new__typerrbytesdecode__str__)rargskwargsvaluers rr$znewstr.__new__Hs  t99>>%%--c22 2$q']]f $ $7N Q ) ) GEE Q ' ' V##s4yy1}}&QQRR;F;;Q))GEVS!!))#u555rcftt|}|ddS)z& Without the u prefix r!N)r#r__repr__)selfr+rs rr-znewstr.__repr__js. fd##,,..QRRyrcnttt||S)z Warning: Python <= 2.7.6 has a bug that causes this method never to be called when y is a slice object. Therefore the type of newstr()[:2] is wrong (unicode instead of newstr). )rr# __getitem__)r.yrs rr0znewstr.__getitem__ss+ eFD))55a88999rcd}t|tkr|}nxt|ts$t|trt |st|}n/t |t|tt|t|S)Nz6'in ' requires string as left operand, not {0}) r%rrrr&r TypeErrorformatr list)r.keyerrmsgnewkeys r __contains__znewstr.__contains__{sI 99  FF W % % 6C)?)? 6 SV 6C[[FFFMM$s))4455 5V d4jj111rnewbytescnttt||Sr)rr#__add__r.otherrs rr<znewstr.__add__s)eFD))11%88999rcD t||zS#tcYSxYw)z left + self )rNotImplemented)r.lefts r__radd__znewstr.__radd__s- "$<<$& & "! ! ! !s cnttt||Sr)rr#__mul__r=s rrDznewstr.__mul__s)eFD))11%88999rcnttt||Sr)rr#__rmul__r=s rrFznewstr.__rmul__s)eFD))22599:::rcd}t|D]6\}}t|r"t||7t |t kr5t t t ||St t t t ||S)Nz7sequence item {0}: expected unicode string, found bytes) enumeraterr3r4r%rr#join)r.iterabler7iitemrs rrIz newstr.joinsJ ** 2 2GAt$ 2 a 0 0111 2 ::  %--228<<== =%t 55::8DDEE ErcFtt|j|g|RSr)r#rfindr.subr)rs rrNz newstr.finds('uVT""'3d3333rcFtt|j|g|RSr)r#rrfindrOs rrRz newstr.rfinds((uVT""(4t4444r)r!cbttt|j||g|RSr)rr#replace)r.oldnewr)rs rrUznewstr.replaces31eFD))1#sBTBBBCCCrc td)N)decode method has been disabled in newstr)AttributeError)r.r)s rr'z newstr.decodesHIIIrutf-8strictcddlm}|dkr|dkrtdg}|D]m}t|}d|cxkrdkr&nn#|||dz gD||| n|d |S|tt|||S) a Returns bytes Encode S using the codec registered for encoding. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors raise a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and 'xmlcharrefreplace' as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors. r)r:surrogateescapezutf-16z?FIXME: surrogateescape handling is not yet implemented properlyiii)r r) future.types.newbytesr:NotImplementedErrorordappendencoderIr#r)r.r errorsr:mybytesccoders rrcz newstr.encodes 322222 & & &8##)+IJJJG @ @1vvT++++V+++++NN88TF]O#<#<====NN188X8#>#>????8C==%%g.. .xfd++228VDDEEErr!ct|trH|D]E}t|r4t|jt |Ftt|j |g|RSr) rr rr3no_convert_msgr4r%r#r startswithr.prefixr)thingrs rrjznewstr.startswiths fh ' ' M M Me$$M#D$7$>$>tE{{$K$KLLLM-uVT""-f$>tE{{$K$KLLLM+uVT""+F:T::::rNcntt|||}d|DS)Nc,g|]}t|Srr.0parts r z newstr.split..///t ///r)r#rsplitr.sepmaxsplitpartsrs rryz newstr.splits8fd##))#x88//////rcntt|||}d|DS)Nc,g|]}t|Srrsrts rrwz!newstr.rsplit..rxr)r#rrsplitrzs rrz newstr.rsplits8fd##**399//////rctt||}td|DS)Nc34K|]}t|VdSrrsrts r z#newstr.partition..(44dVD\\444444r)r#r partitiontupler.r{r}rs rrznewstr.partitions=fd##--c2244e444444rctt||}td|DS)Nc34K|]}t|VdSrrsrts rrz$newstr.rpartition.. rr)r#r rpartitionrrs rrznewstr.rpartitions=fd##..s3344e444444rcL|j|g|R}|dkrtd|S)zb Like newstr.find() but raise ValueError when the substring is not found. rpzsubstring not found)rN ValueError)r.rPr)poss rindexz newstr.index s: di#d### "99233 3 rFcltt||}d|DS)z S.splitlines(keepends=False) -> list of strings Return a list of the lines in S, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true. c,g|]}t|Srrsrts rrwz%newstr.splitlines..!rxr)r#r splitlines)r.keependsr}rs rrznewstr.splitliness6fd##..x88//////rct|ts$t|tr7t|s(t t ||StSr)rrr&rr#r__eq__r@r=s rrz newstr.__eq__#s[ ug & & " ue $ $ "-7->-> "&&--e44 4! !rct|ts$t|tr6t|s't t |Str)rrr&rr#r__hash__r`)r.rs rrznewstr.__hash__*s_ tW % % ( tU # # (,6t,<,< (&&//11 1%'' 'rct|ts$t|tr7t|s(t t ||SdS)NT)rrr&rr#r__ne__r=s rrz newstr.__ne__1sZ ug & &  ue $ $ -7->-> &&--e44 44rz unorderable types: str() and {0}c.t|ts$t|tr7t|s(t t ||St|j t|r) rrr&rr#r__lt__r3unorderable_errr4r%r=s rrz newstr.__lt__:z ug & & 5 ue $ $ 5-7->-> 5&&--e44 4,33DKK@@AAArc.t|ts$t|tr7t|s(t t ||St|j t|r) rrr&rr#r__le__r3rr4r%r=s rrz newstr.__le__@rrc.t|ts$t|tr7t|s(t t ||St|j t|r) rrr&rr#r__gt__r3rr4r%r=s rrz newstr.__gt__Frrc.t|ts$t|tr7t|s(t t ||St|j t|r) rrr&rr#r__ge__r3rr4r%r=s rrz newstr.__ge__Lrrcz|dvrtdtt||S)zu A trick to cause the ``hasattr`` builtin-fn to return False for the 'decode' method on Py2. )r'r'rY)rZr#r__getattribute__)r.namers rrznewstr.__getattribute__Rs> ( ( ( !LMM MVT""33D999rc t|S)z@ A hook for the future.utils.native() function. )rr.s r __native__znewstr.__native__[st}}rc|y|Jt|tstdi}|D]9\}}t |dkrt d||t |<:nt|ts$t|trtdt |t |kst di}t||D]F\}}t |dkrt dt ||t |<G||D]}d|t |<|S)a_ Return a translation table usable for str.translate(). If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result. Nz str Return a copy of the string S, where all characters have been mapped through the given translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None. Unmapped characters are left untouched. Characters mapped to None are deleted. N)rarrrbchrrI)r.tablelrfvals r translateznewstr.translates   A1vvCFFm;W--'HHSMMMMHHSXX&&&& wwqzzrc tdNfixmer`rs r isprintableznewstr.isprintable!'***rc tdrrrs r isidentifierznewstr.isidentifierrrc tdrrrs r format_mapznewstr.format_maprr)r[r\)Nrp)F)NN)-rrr__doc__rir$r-r0r9rr<rBrDrFrIrNrRrUr'rcrjroryrrrrrrrrrrrrrrr staticmethodrrrrr __classcell__)rs@rrrBsDN 6 6 6 6 6D::::: 2 2 2R ^^::::^:R ^^""^":::::;;;;; F F F F FR ^^4444^4R ^^5555^5R FDDDDDJJJ'F'F'F'F'F'FRR A=====R A ; ; ; ; ;R A000000 R A000000 R A55555R A55555R A 0 0 0 0 0 0"""""(((((9OBBBBB BBBBB BBBBB BBBBB ::::: $$$\$L0+++++++++++++rrN)rnumbersr future.utilsrrrr future.typesrr future.types.newobjectr strrcollections.abcr collectionsr%r r__all__rrrrs((T@@@@@@@@@@@@%%%%%%%%,,,,,,%G((((((($$$$$$77777777e+e+e+e+e+^^J 0 0e+e+e+P *r