ؘsWdZddlmZddlZddlZddlmZmZmZm Z m Z ddl m Z m Z ddlmZerddlmZnddlmZeZe reZGdd eZd ZGd d e eeZd gZdS) z Pure-Python implementation of a Python 3-like bytes object for Python 2. Why do this? Without it, the Python 2 bytes object is a very, very different beast to the Python 3 bytes object. )IntegralN)istextisbytesPY2PY3with_metaclass)noissubset) newobject)IterableceZdZdZdS) BaseNewBytescl|tkrt|tSt|j|SN)newbytes isinstance_builtin_bytes issubclass __class__)clsinstances g/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/future/types/newbytes.py__instancecheck__zBaseNewBytes.__instancecheck__s. (??h77 7h0#66 6N)__name__ __module__ __qualname__rrrrrs#77777rrctt|tr|dSt|S)Nascii)rstrencodechr)xs r_newchrr%%s1!Sxx   1vv rcHeZdZdZfdZfdZfdZfdZdZdZ e e fdZ e e d Z e e fd Ze e fd Zd Zd ZfdZedZe e fdZe e fdZe e dfdZdZd3fd Ze e fdZe e fdZe e d4fd Zd5fd Ze e d4fd Ze e fd Ze e fd!Z e e d"d#Z!e e fd$Z"fd%Z#fd&Z$d'Z%fd(Z&fd)Z'fd*Z(fd+Z)fd,Z*fd-Z+e e d6fd. Z,e e d6fd/ Z-fd0Z.e e fd1Z/ee e d2Z0xZ1S)7rz8 A backport of the Python 3 bytes object to Py2 cvd}d}t|dkr(tt||St|dkrJt |}t|dkr|}|}t |dtkr|dSt|dtr |d}n}t|dtr{ d|vr |J|d}d|vr |J|d}n#t$rtdwxYw|td|g}|| ||dj |}nt|dd r|d}nt|dt rQt|ddkrd }n t#d |dD}n^#t%d xYwt|dt&r'|ddkrt%d d|dz}n|d}t |tkrt)j|Stt|||S)aK From the Py3 bytes docstring: bytes(iterable_of_ints) -> bytes bytes(string, encoding[, errors]) -> bytes bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer bytes(int) -> bytes object of size given by the parameter initialized with null bytes bytes() -> empty bytes object Construct an immutable array of bytes from: - an iterable yielding integers in range(256) - a text string encoded using the specified encoding - any object implementing the buffer API. - an integer Nrencodingerrorsz#Argument given by name and positionz+unicode string argument without an encoding __bytes__rc,g|]}t|Sr)r%).0r$s r z$newbytes.__new__..ws&C&C&Cawqzz&C&C&Crzbytes must be in range(0, 256)znegative count)lensuperr__new__listpoptyperrunicodeAssertionError TypeErrorappendr"hasattrr,r bytearray ValueErrorrcopy)rargskwargsr*r+valuenewargsrs rr3znewbytes.__new__0s" t99>>3''//44 4 YY!^^::D4yyA~~XXZZH Q==H $ $7N Q 0 0+ GEE Q ) ))  G''#+++%j1Hv%%!>>>#H-F! G G G EFFF G MNNN  jG!v&&&"DGNG,EE T!Wk * * G%%''EE Q * * 47||q   G%&C&C47&C&C&CDDEEG$%EFFF Q * * Aw{{ !1222d1g%EEGE ;;( " " 9U## #3''//U;; ;s D&&E(HHcXdtt|zS)Nb)r2r__repr__selfrs rrEznewbytes.__repr__s$U8T**335555rc~ddtt|zS)NrDz'{0}')formatr2r__str__rFs rrJznewbytes.__str__s0W^^E(D$9$9$A$A$C$CDDDDrctt||}t|trt |St|Sr)r2r __getitem__rrord)rGyrArs rrLznewbytes.__getitem__sJh%%11!44 a " " #u:: E?? "rc:|t|Sr)rLslicerGr?s r __getslice__znewbytes.__getslice__st ---rct|trt|g}n*t|tkr|}nt|}t t |t |Sr)rintrr6r r4)rGkey newbyteskeys r __contains__znewbytes.__contains__sf c3   ("C5//KK#YY( " "KK"3--K[))4::666rcnttt||Sr)rr2__add__rGotherrs rrYznewbytes.__add__)h--55e<<===rc&t||zSrr)rGlefts r__radd__znewbytes.__radd__s~~$$rcnttt||Sr)rr2__mul__rZs rrbznewbytes.__mul__r\rcnttt||Sr)rr2__rmul__rZs rrdznewbytes.__rmul__s)h--66u==>>>rcdt|trt|}nt|tr[g}|D]F}t|trt|}||Gt |}nvt |jdrat |jdrL|D]7\}}t|trt|||<8t ||S)NrL iteritems) rrrrJtupler:r;rrf__mod__)rGvalsnewvalsvks rrhznewbytes.__mod__s dH % % 8!))$//DD e $ $ 8G " "a**2&..q11Aq!!!!>>DDdnm44 8 44 8(( 8 81a**8,44Q77DG%%dD111rc,||Sr)rh)rGr[s r__imod__znewbytes.__imod__s||E"""rc d}t|st|r0t|dt |t |D]D\}}t|r0t||t |Et tt ||S)Nz,sequence item {0}: expected bytes, {1} foundr) rrr9rIr6 enumeraterr2join)rGiterable_of_byteserrmsgiitemrs rrqz newbytes.joins? $ % % G0A)B)B GFMM!T2C-D-DEEFF F !233 > >GAtd|| > ad < <=== >h--223DEEFFFrc\||jdddS)N hex)replacedecode)rstrings rfromhexznewbytes.fromhexs0s>6>#r**11%88999rcFtt|j|g|RSr)r2rfindrGsubr?rs rrz newbytes.finds()uXt$$)#55555rcFtt|j|g|RSr)r2rrfindrs rrznewbytes.rfinds(*uXt$$*366666r)r(cbttt|j||g|RSr)rr2rz)rGoldnewr?rs rrzznewbytes.replaces35h--5c3FFFFGGGrc td)N+encode method has been disabled in newbytes)AttributeErrorrQs rr"znewbytes.encodesJKKKrutf-8strictcddlm}|dkrddlm}||t t |||S)a Returns a newstr (i.e. unicode subclass) Decode B 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 UnicodeDecodeError. Other possible values are 'ignore' and 'replace' as well as any other name registered with codecs.register_error that is able to handle UnicodeDecodeErrors. r)newstrsurrogateescape)register_surrogateescape)future.types.newstrrfuture.utils.surrogateescaperr2rr{)rGr*r+rrrs rr{znewbytes.decodesn /..... & & & M M M M M M $ $ & & &veHd++228VDDEEErcFtt|j|g|RSr)r2r startswithrGprefixr?rs rrznewbytes.startswiths(/uXt$$/>>>>>rcFtt|j|g|RSr)r2rendswithrs rrznewbytes.endswiths(-uXt$$-f.'1114111r)r2rsplitrGsepmaxsplitpartsrs rrznewbytes.split"s8h%%++C::1151111rFcltt||}d|DS)z B.splitlines([keepends]) -> list of lines Return a list of the lines in B, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true. c,g|]}t|Srr^rs rr/z'newbytes.splitlines..4rr)r2r splitlines)rGkeependsrrs rrznewbytes.splitlines)s6h%%00::1151111rcntt|||}d|DS)Nc,g|]}t|Srr^rs rr/z#newbytes.rsplit..;rr)r2rrsplitrs rrznewbytes.rsplit6s8h%%,,S(;;1151111rctt||}td|DS)Nc34K|]}t|VdSrr^rs r z%newbytes.partition..@(66Xd^^666666r)r2r partitionrgrGrrrs rrznewbytes.partition=s=h%%//4466666666rctt||}td|DS)Nc34K|]}t|VdSrr^rs rrz&newbytes.rpartition..Err)r2r rpartitionrgrs rrznewbytes.rpartitionBs=h%%005566666666r)rcL|j|g|R}|dkrtddS)z S.rindex(sub [,start [,end]]) -> int Like S.rfind() but raise ValueError when the substring is not found. rsubstring not foundN)rr=)rGrr?poss rrindexznewbytes.rindexGs<dj$t$$$ "99233 3 9rcrt|trt|dkrdt|}}nDt|dkr |d}n(t|dkr|\}}ntdt ||||St|t s; ||}n$#ttf$rtdwxYw tt|j|g|RS#t$rtdwxYw)z Returns index of sub in bytes. Raises ValueError if byte is not in bytes and TypeError if can't be converted bytes or its length is not 1. rrr(ztakes at most 3 argumentszcan't convert sub to bytesr) rrTr1r9r4indexbytesrr=r2r)rGrr?startendrs rrznewbytes.indexRsJ c3   44yyA~~D sTaQTa! ss ;<<<::eCi(..s33 3#u%% > >nnS))z* > > > <=== > 4.54((.s:T::: : 4 4 4233 3 4sC!C7; DD6ct|ttfr(tt||SdS)NF)rrr<r2r__eq__rZs rrznewbytes.__eq__ms= eni8 9 9 4((//66 65rct|tr(tt||SdS)NT)rrr2r__ne__rZs rrznewbytes.__ne__ss8 e^ , , 4((//66 64rz"unorderable types: bytes() and {0}ct|tr(tt||St |jt|r) rrr2r__lt__r9unorderable_errrIr6rZs rrznewbytes.__lt__{X e^ , , 74((//66 6,33DKK@@AAArct|tr(tt||St |jt|r) rrr2r__le__r9rrIr6rZs rrznewbytes.__le__rrct|tr(tt||St |jt|r) rrr2r__gt__r9rrIr6rZs rrznewbytes.__gt__rrct|tr(tt||St |jt|r) rrr2r__ge__r9rrIr6rZs rrznewbytes.__ge__rrcRtt|Sr)r2rrJrFs r __native__znewbytes.__native__s!Xt$$,,...rcz|dvrtdtt||S)zu A trick to cause the ``hasattr`` builtin-fn to return False for the 'encode' method on Py2. )r"r"r)rr2r__getattribute__)rGnamers rrznewbytes.__getattribute__s> ( ( ( !NOO OXt$$55d;;;rcnttt||S)z Strip trailing bytes contained in the argument. If the argument is omitted, strip trailing ASCII whitespace. )rr2rstriprGbytes_to_striprs rrznewbytes.rstrips+ h--44^DDEEErcnttt||S)z Strip leading and trailing bytes contained in the argument. If the argument is omitted, strip trailing ASCII whitespace. )rr2striprs rrznewbytes.strips+ h--33NCCDDDrclttt|S)zv b.lower() -> copy of b Return a copy of b with all ASCII characters converted to lowercase. )rr2lowerrFs rrznewbytes.lowers) h--3355666rclttt|S)zv b.upper() -> copy of b Return a copy of b with all ASCII characters converted to uppercase. )rr2upperrFs rrznewbytes.uppers)h--3355666rcFttj||S)aT B.maketrans(frm, to) -> translation table Return a translation table (a bytes object of length 256) suitable for use in the bytes or bytearray translate method where each byte in frm is mapped to the byte at the same position in to. The bytes objects frm and to must be of the same length. )rr| maketrans)rfrmtos rrznewbytes.maketranss(b11222r)rr)Nr)Fr)2rrr__doc__r3rErJrLrRrWr r7rYr`rbrdrhrnrq classmethodr}rrrzr"r{rrrrrrrrrrrrrrrrrrrrrrr __classcell__)rs@rrr,sX<X<X<X<X>>>[>R[[%%[%R[[>>>>[>R[[????[?222(###GGGGG::[:R[[6666[6R[[7777[7RHHHHHLLLFFFFFFbR[[????[?R[[====[=R[[22222[2 2 2 2 2 2 2R[[22222[2 R[[7777[7R[[7777[7R444R[[4444[44  ;OBBBBB BBBBB BBBBB BBBBB ///// <<<<<R[[FFFFF[FR[[EEEEE[E77777R[[7777[7R[[ 3 3[[ 3 3 3 3 3rr)rnumbersrr|r> future.utilsrrrrr future.typesr r future.types.newobjectr collectionsr collections.abcrrr!r7r6rr%r__all__rrrrsQ BBBBBBBBBBBBBB%%%%%%%%,,,,,,)$$$$$$$((((((G777774777]3]3]3]3]3~~lN;;]3]3]3@ ,r