var/opt/nydus/ops/primordial/__pycache__/sizes.cpython-38.pyc000064400000033520147205526440020254 0ustar00U af 1 @sddlZddlmZmZmZddddddd d d g ZGd d d ZGdddeZGdddeZGdddeZ GdddeZ GdddZ dS)N)ListOptionalTupleBKiBMiBGiBTiBPiBEiBZZiBZYiBc @seZdZdZdTeeeeeeeddddZeeeefddd Z edd d Z edd d Z edddZ edddZ edddZeedddZeedddZeedddZeedddZeedddZeedddZeedd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Z d4d5Z!d6d7Z"d8d9Z#d:d;Z$dd?Z&d@dAZ'dBdCZ(dDdEZ)dFdGZ*dHdIZ+dJdKZ,dLdMZ-dNdOZ.dPdQZ/dRdSZ0dS)UByteSizez*Encapsulation for tracking sizes in bytes.rN)BytesKiBytesMiBytesGiBytesTiBytesPiBytesEiBytesreturncCsVt|dt|dt|dt|dt|dt|dt||_dS)N)int_bytes)selfr rrrrrrrA/opt/nydus/tmp/pip-target-53d1vnqk/lib/python/primordial/sizes.py__init__ s zByteSize.__init__rcCsNg}|j}tD]4}|d@}|r.|d||f|dL}|dkrqDq|pLdgS)Nir )r)r _sizeUnitsinsert)rsresZcsizesizeZsvalrrr _breakdownszByteSize._breakdowncCsddd|DS)N,cSsg|] }d|qS%d%sr.0Zeachrrr *sz$ByteSize.__str__..joinr#rrrr__str__)szByteSize.__str__cCs$d|jjddd|DS)Nz{}({})r$cSs g|]\}}d|pd|qS)z {}ytes={}r)format)r(VUrrrr)/sz%ByteSize.__repr__..)r. __class____name__r+r#r,rrr__repr__,szByteSize.__repr__cCs@|}dt|dkr"|ddn|ddd|ddfS)z-Return the size in simple form (int ceiling).r&r)r#len)rbdrrr simpleSizeStr2szByteSize.simpleSizeStrcCs|}t|dksRt|ddt|dddkr^t|dddkr^d|dS|ddd|ddd}d|}|dr|dd |ddS||ddS) zAReturn the size in floating point form to two significant digits.r4rrr&@z%.2fz.00N)r#r5rindexendswith)rr6ZfvZrsprrr approxSizeStr7s   zByteSize.approxSizeStrcCsddd|DS)z%Return the size in full detail units.r$cSsg|] }d|qSr%rr'rrrr)Esz(ByteSize.fullSizeStr..r*r,rrr fullSizeStrCszByteSize.fullSizeStrcCs|jSNrr,rrrr GszByteSize.BytescCs |jdSNr8r r,rrrrKszByteSize.KiBytescCs |jdSr@)rr,rrrrOszByteSize.MiBytescCs |jdSr@)rr,rrrrSszByteSize.GiBytescCs |jdSr@)rr,rrrrWszByteSize.TiBytescCs |jdSr@)rr,rrrr[szByteSize.PiBytescCs |jdSr@)rr,rrrr_szByteSize.EiBytescCs|jSr>r?r,rrr __trunc__cszByteSize.__trunc__cCs|jSr>r?r,rrr __index__fszByteSize.__index__cCsD|dkr|jdkSz|j|jkWStk r>|j|kYSXdSNrrAttributeErrorrorrr__eq__js  zByteSize.__eq__cCsD|dkr|jdkSz|j|jkWStk r>|j|kYSXdSrDrErGrrr__ne__rs  zByteSize.__ne__cCsD|dkr|jdkSz|j|jkWStk r>|j|kYSXdSrDrErGrrr__gt__zs  zByteSize.__gt__cCsD|dkr|jdkSz|j|jkWStk r>|j|kYSXdSrDrErGrrr__ge__s  zByteSize.__ge__cCs>|dkr dSz|j|jkWStk r8|j|kYSXdS)NFrErGrrr__lt__s zByteSize.__lt__cCsD|dkr|jdkSz|j|jkWStk r>|j|kYSXdSrDrErGrrr__le__s  zByteSize.__le__cCs,t|dr||j|jS||j|SNr)hasattrr1rrGrrr__add__s zByteSize.__add__cCs.t|dr|j|j7_n|j|7_|SrO)rPrrGrrr__iadd__s zByteSize.__iadd__cCs<t|dr$|jtd|j|jdS|jtd|j|dS)NrrrA)rPr1maxrrGrrr__sub__s zByteSize.__sub__cCs4t|dr"|jt|jd8_n|j|8_|S)Nrr)rPrrSrGrrr__isub__s zByteSize.__isub__cCs|j|j|dSNrAr1rrGrrr__mul__szByteSize.__mul__cCs|j|j|dSrVrWrGrrr__rmul__szByteSize.__rmul__cCs|j|9_|Sr>r?rGrrr__imul__szByteSize.__imul__cCs*t|tr|j|jS|t|j|Sr> isinstancer rr1rrGrrr __floordiv__s  zByteSize.__floordiv__cCs ||jt|tr|jn|Sr>)r1rr\r rGrrr__mod__szByteSize.__mod__cCs||||fSr>rrGrrr __divmod__szByteSize.__divmod__cCs.t|tr|jd|jS|t|j|S)Ng?r[rGrrr __truediv__s zByteSize.__truediv__cCs|j|_t|j|_|Sr>rrrGrrr__idiv__s zByteSize.__idiv__cCs ||Sr>)rbrGrrr __itruediv__szByteSize.__itruediv__cCs|j|_t|j|_|Sr>rarGrrr __ifloordiv__s zByteSize.__ifloordiv__cCs|j|;_t|j|_|Sr>rarGrrr__imod__s zByteSize.__imod__cCs t|jSr>boolrr,rrr __nonzero__szByteSize.__nonzero__cCs t|jSr>rfr,rrr__bool__szByteSize.__bool__)rrrrrrr)1r2 __module__ __qualname____doc__rrrrstrr#r-r3r7r<r=propertyr floatrrrrrrrBrCrIrJrKrLrMrNrQrRrTrUrXrYrZr]r^r_r`rbrcrdrerhrirrrrr s~    r c@seZdZdZdS)MemSizez+Encapsulation for tracking amount of memoryNr2rjrkrlrrrrrpsrpc@seZdZdZdS)DiskSizez_invValrZ invalid_valuerrrrszInvalidMemSize.__init__cCsdt|jS)NzInvalidMemSize "%s"rmrur,rrrr-szInvalidMemSize.__str__cCsdt|jS)NzInvalidMemSize(%s)reprrur,rrrr3szInvalidMemSize.__repr__cCs t|tSr>r\rsrGrrrrIszInvalidMemSize.__eq__cCs t|t Sr>rzrGrrrrJszInvalidMemSize.__ne__Nr2rjrkrr-r3rIrJrrrrrss rsc@s4eZdZddZddZddZddZd d Zd S) InvalidDiskSizecCs ||_dSr>rtrvrrrr szInvalidDiskSize.__init__cCsdt|jS)NzInvalidDiskSize "%s"rwr,rrrr- szInvalidDiskSize.__str__cCsdt|jS)NzInvalidDiskSize(%s)rxr,rrrr3szInvalidDiskSize.__repr__cCs t|tSr>r\r|rGrrrrIszInvalidDiskSize.__eq__cCs t|t Sr>r}rGrrrrJszInvalidDiskSize.__ne__Nr{rrrrr|s r|c@seZdZdZdeddddZddZed d d Zee d d d Z ee d ddZ ee d ddZ ed ddZ ed ddZd ee edddZd!ee eedddZd"ee eedddZdS)# ByteSizeszEncapsulation for an aggregation of byte size values. The naturalUnits indicates which units to report sizes in if the size is not indicated or is a close approximation of those units (naturalUnits should be one of _sizeUnits) rN) naturalUnitsrcCs0td|_d|_td|_d|_||_d|_dSrD)r _accum_minSize_maxSize _numSizes_natUnit _sumUnits)rrrrrr"s   zByteSizes.__init__cCsdt|tst|d}|j|7_|jd7_|jdksD||jkrJ||_||jkrZ||_d|_|S)NrAr4)r\r rrrrrrGrrrrR*s   zByteSizes.__iadd__rcCs t|jSr>)rmrr,rrrr-6szByteSizes.__str__cCs|jdkrtdS|jSrD)rr r,rrr minimumSize9szByteSizes.minimumSizecCs|jSr>)rr,rrr maximumSize=szByteSizes.maximumSizecCs|jdkrtdS|j|jSrD)rr rr,rrr averageSizeAszByteSizes.averageSizecCs|ttd}tttdddD]T}td|d}||jkr>q |dt|jkrj|j|dkrj|jSt|S|jS)Nr4rrAd)r5rranger rr:r)rZsuIZbaseSizerrr_calcSummaryUnitsEs  "  zByteSizes._calcSummaryUnitscCs|jdkr||_|jSr>)rrr,rrr summaryUnitsPs  zByteSizes.summaryUnits)ofSizercCs|dkr|jS|S)zrReturn the specified size (or total size) in full detail units. :param: The size to be displayed N)rr=)rrrrrr=Us zByteSizes.fullSizeStrF)r withUnitsrc Csf|dkr|jSt|j|j|j|j|j|j|j |j d| }|rZd|| fSt t |S)agReturns the specified size (or total size) in simple form (int ceiling) based on the summary Units. The withUnits can be used to enable or suppress reporting of units in the output (units are summaryUnits() in either case). :param ofSize: The size to simplify :param withUnits: Whether to include units in the output Nrrrrrr r r r&)rr7mathceilr rrrrrrrrmrrrrvalrrrr7^s  zByteSizes.simpleSizeStrc Csd|dkr|jSt|j|j|j|j|j|j|j|j d| dd}d||r\| ndfS)aGive a string representation of a close approximation of the size. Returns the specified size (or total size) in floating point form to two significant digits, based on the on the summary Units. The withUnits can be used to enable or suppress reporting of units in the output (units are summaryUnits() in either case). :param ofSize: The size to be represented :param withUnits: Whether to include units in the output Nrr8z%.2f%sr) rr<rr rrrrrrrrrrrr<us$  zByteSizes.approxSizeStr)r)N)NF)NF)r2rjrkrlrmrrRr-rnr rrrrrrr=rgr7r<rrrrr~s   r~) rtypingrrrrr rprrrsr|r~rrrrsc