Mini Shell

Direktori : /lib64/python3.6/site-packages/parted/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/parted/__pycache__/geometry.cpython-36.pyc

3

�XZ� �@s@ddlZddlZddlZddlZddlmZGdd�de�ZdS)�N)�localeCc@seZdZdZed/dd��Zdd�Zdd�Zd	d
�Ze	dd��Z
e	d
d�dd��Ze	dd�dd��Ze	dd�dd��Z
ed0dd��Zedd��Zedd��Zed1dd��Zed2dd��Zed d!��Zed"d#��Zed$d%��Zed&d'��Zed3d)d*��Zed+d,��Zd-d.�ZdS)4�Geometrya$Geometry()

       Geometry represents a region on a device in the system - a disk or
       partition.  It is expressed in terms of a starting sector and a length.
       Many methods (read and write methods in particular) throughout pyparted
       take in a Geometry object as an argument.NcCs�|r.||_|dkr&tj|jjd�|_q�||_n�|sP||_tj|jj�||�|_nx|r�||kr�||_tj|jj�|||d|d�|_n@|r�|r�|r�||kr�||_tj|jj�|||d�|_n
tj	d��dS)z�Create a new Geometry object for the given _ped.Device that extends
           for length sectors from the start sector.  Optionally, an end sector
           can also be provided.N)Z	PedDevice�)�endzkmust specify PedGeometry or (device, start, length) or (device, start, end) or (device, start, length, end))
�_Geometry__geometry�partedZDeviceZdev�_device�_pedr�deviceZgetPedDeviceZGeometryException)�selfr
�start�lengthr�PedGeometry�r� /usr/lib64/python3.6/geometry.py�__init__)s$zGeometry.__init__cCs|j|�S)N)�__ne__)r�otherrrr�__eq__BszGeometry.__eq__cCs4t||j�sdS|j|jkp2|j|jkp2|j|jkS)NT)�
isinstance�	__class__r
rr
)rrrrrrEszGeometry.__ne__cCs"d|j|j|j|j|jd�}|S)Nz{parted.Geometry instance --
  start: %(start)s  end: %(end)s  length: %(length)s
  device: %(device)r  PedGeometry: %(ped)r)rrr
r
Zped)rrr
r
r)r�srrr�__str__KszGeometry.__str__cCs|jS)z#The Device this geometry describes.)r)rrrrr
SszGeometry.devicecCs|jjS)N)rr)rrrr�<lambda>XszGeometry.<lambda>cCs|jj|�S)N)rZ	set_start)r�vrrrrXscCs|jjS)N)rr)rrrrrYscCs|jj|�S)N)rZset_end)rrrrrrYscCs|jjS)N)rr
)rrrrrZscCs|jj|jj|�S)N)r�setr)rrrrrrZscCs*|s|jj|||�S|jj||||�SdS)a5Check the region described by self for errors on the disk.
           offset -- The beginning of the region to check, in sectors from the
                     start of the geometry.
           granularity -- How sectors should be grouped together
           count -- How many sectors from the region to check.N)r�check)r�offsetZgranularity�countZtimerrrrr\szGeometry.checkcCs|jj|j��S)zgReturn whether Geometry b is contained entirely within self and on
           the same physical device.)rZtest_inside�getPedGeometry)r�brrr�containshszGeometry.containscCs|jj|�S)z=Return whether the sectory is contained entirely within self.)rZtest_sector_inside)r�sectorrrr�containsSectornszGeometry.containsSector�MBcCsRtjdt�|j�}|j|jj}|tjj	�kr<t
d|��|tjdtj|�S)aWReturn the size of the geometry in the unit specified.  The unit
           is given as a string corresponding to one of the following
           abbreviations:  b (bytes), KB (kilobytes), MB (megabytes), GB
           (gigabytes), TB (terabytes).  An invalid unit string will raise a
           SyntaxError exception.  The default unit is MB.zuse the getLength methodzinvalid unit %s giveng�@)
�warnings�warn�DeprecationWarning�lowerr
r
�
sectorSizerZ	_exponent�keys�SyntaxError�math�pow)r�unitZlunit�sizerrr�getSizesszGeometry.getSize�sectorscCs&|j}|dkr|Stj||jj|�S)z�Return the length of the geometry in sectors. Optionally, a SI or
           IEC prefix followed by a 'B' may be given in order to convert the
           length into bytes. The allowed values include B, kB, MB, GB, TB, KiB,
           MiB, GiB, and TiB.r1)r
rZformatBytesr
r))rr.r1rrr�	getLength�szGeometry.getLengthcCst|jj|j��d�S)z�Return a new Geometry describing the region common to both self
           and Geometry b.  Raises ArithmeticError if the regions do not
           intersect.)r)rr�	intersectr)rr rrrr3�szGeometry.intersectcCstj|jj|j�|�d�S)z�Given a Geometry src that overlaps with self and a sector inside src,
           this method translates the address of the sector into an address
           inside self.  If self does not contain sector, ArithmeticError will
           be raised.)r)rrr�mapr)r�srcr"rrrr4�szGeometry.mapcCs.y|jj|j��dStk
r(dSXdS)zgReturn whether self and b are on the same device and share at least
           some of the same region.TFN)rr3r�ArithmeticError)rr rrr�overlapsWith�s
zGeometry.overlapsWithcCs|jj||�S)z�Read data from the region described by self.
           offset -- The number of sectors from the beginning of the region
                     (not the beginning of the disk) to read.
           count  -- The number of sectors to read.)r�read)rrrrrrr8�sz
Geometry.readFcCs|r|jj�S|jj�SdS)z�Flushes all caches on the device described by self.  If fast is
           True, the flush will be quicked by cache coherency is not
           guaranteed.N)rZ	sync_fast�sync)rZfastrrrr9�s
z
Geometry.synccCs|jj|||�S)a1Write data into the region described by self.
           buf    -- The data to be written.
           offset -- Where to start writing to region, expressed as the number
                     of sectors from the start of the region (not the disk).
           count  -- How many sectors of buf to write out.)r�write)rZbufrrrrrr:�szGeometry.writecCs|jS)zdReturn the _ped.Geometry object contained in this Geometry.
           For internal module use only.)r)rrrrr�szGeometry.getPedGeometry)NNNNN)N)r$)r1)F)�__name__�
__module__�__qualname__�__doc__rrrrr�propertyr
rrr
rr!r#r0r2r3r4r7r8r9r:rrrrrr"s6

		r)r,r%rr	Zparted.decoratorsr�objectrrrrr�<module>s