HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyo
ó
.Åt_c@s<dZddlZddlmZdefd„ƒYZdS(sw
  SizeString - LVM-style size strings

  $Id: //eng/vdo-releases/magnesium/src/python/vdo/vdomgmnt/SizeString.py#1 $

iÿÿÿÿNi(t	Constantst
SizeStringcBs›eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„Zd
„Zd„Zed„ƒZRS(sòRepresents the size of an object such as a disk partition.

  Conversions are provided to and from suffixed size strings as used
  by LVM commands like lvcreate(8). These strings consist of a
  (possibly floating-point) number followed by an optional unit
  suffix: B (bytes), S (512-byte sectors), and KMGTPE for kilobytes
  through exabytes, respectively. Suffixes are not case-sensitive; the
  default unit is Megabytes. Currently, we reject negative sizes.

  Unlike some (but not all) LVM commands we do not interpret the upper-case
  version of a suffix as a power of ten.

  Attributes:
    _originalString (str): the original string we were constructed
      with, mainly used for debugging
    _bytes (int): the value of this object in bytes

  cCs&tdƒ}|jt|ƒ|_|S(Nt(Rt_bytestint(tselftrhstretval((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__add__4scCs
|jdkS(Ni(R(R((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__bool__:scCs:d}t|tƒst}nt|j|jƒƒ}|S(Ni(t
isinstanceRtNotImplementedtcmpRttoBytes(RRtresult((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__cmp__>s
	cCs|jt|ƒ7_|S(N(RR(RR((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__iadd__GscCs|jS(N(R(R((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__int__LscCs
|jƒS(N(R	(R((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__nonzero__PscCstj}|j}|dkr|x[tjddd…D]7}tj|}||dkr5||}|}Pq5q5Wtj}nt|ƒ|jƒS(s=Returns this object as a size string without a decimal point.iNiÿÿÿÿ(RtlvmDefaultSuffixRt
lvmSiSuffixestlvmSiSuffixSizeMapt
lvmByteSuffixtstrtupper(Rtsuffixtsizetclicktdivisor((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt	asLvmTextTs		

cCs|jƒtj|_|S(s8Rounds this object down to a multiple of the block size.(ttoBlocksRtVDO_BLOCK_SIZER(R((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pytroundToBlockescCs|jtjS(s;Returns this object as a count of 4K blocks, rounding down.(RRR(R((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyRkscCs|jS(s6Returns the count of bytes represented by this object.(R(R((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyR
pscCs#tjtj}|j|d|S(s@Returns this object as a count of 512-byte sectors, rounding up.i(RtlvmSuffixSizeMaptlvmSectorSuffixR(RtbytesPerSector((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt	toSectorsuscCsø||_|rëyQ|djƒ}|tjkrG|j|d ƒ}n|j|ƒ}tj}Wn/tk
r‘ttdƒjd|ƒƒ‚nX|t	tj
|ƒ9}t|ƒ|_|jdkrôttdƒjd|ƒƒ‚qôn	d|_dS(Niÿÿÿÿsinvalid size string "{size}"Ri(
t_originalStringtlowerRtlvmSuffixest_atofRt
ValueErrort_tformattfloatR!RR(RtszRtnbytes((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__init__}s	

"$cCs"dj|j|jtjjƒƒS(Ns{0} ({1}{2})(R+R%RRRR(R((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__repr__‘scCs
|jƒS(N(R(R((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt__str__—scCs0ytj|ƒSWntk
r+t|ƒSXdS(spTries to convert a float using the current LC_NUMERIC settings.
    If something goes wrong, tries float().
    N(tlocaletatoft	ExceptionR,(ts((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyR(s
(t__name__t
__module__t__doc__RR	RRRRRR RR
R$R/R0R1tstaticmethodR((((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyRs 															(R8R2RRtobjectR(((s;/usr/lib/python2.7/site-packages/vdo/vdomgmnt/SizeString.pyt<module>s