
    w]'                         d dl Z d dlZd dlZd dlZd dlmZ  G d de      Zi Z ej                  d       Z
 ej                  e
      ee
<   dZer0 ej                  e
      Z
e
sdZn ej                  e
      ee
<   er/yy)    N)localeCc                      e Zd Zed#d       Zd Zd Zd Zd Ze	ed               Z
e	ed               Ze	d	        Ze	ed
               Ze	d        Zed        Zd Z e	d d       Z e	d d       Z e	d d       Z e	d d       Z e	ee      Zed        Zed        Zed        Zed        Zed        Zed        Zed$d       Zed%d       Zd Zd$dZd  Z d! Z!d" Z"y)&	PartitionNc                    ||t        j                  d      |t        j                  d      |t        j                  d      || _        || _        || _        |@t        j                  |j                         ||j                  |j                        | _
        y t        j                  |j                         ||j                  |j                  t         j                  |j                           | _
        y || _
        t        j                  | j                  j                        | _        |0t        j                  | j                  j                         | _        n|| _        | j                  j"                  d | _        y t        j$                  | j                  j"                  j&                  | j                        | _        y )Nzno disk specifiedzno type specifiedzno geometry specifiedPedGeometry)PedDisk)typegeometry)partedPartitionException_fileSystem	_geometry_disk_pedr   
getPedDiskstartend_Partition__partitionfileSystemTyper
   GeometrygeomDiskdiskfs_type
FileSystemname)selfr   r
   fsr   PedPartitions         2/usr/lib/python3/dist-packages/parted/partition.py__init__zPartition.__init__&   sy   |//0CDD//0CDD!//0GHH!D%DNDJz#'>>$//2CT8>>[c[g[g#h #'>>$//2CT8>>[c[g[gioi~i~  @B  @G  @G  jH  $I +D#__9I9I9N9NODN|#[[1A1A1F1FG
!
''/#'  $*#4#4$:J:J:R:R:W:Wbfbpbp#q     c                 &    | j                  |       S N)__ne__r   others     r!   __eq__zPartition.__eq__G   s    ;;u%%%r#   c                    t        | |j                        sy| j                  |j                  k7  xsO | j                  |j                  k7  xs4 | j                  |j                  k7  xs | j
                  |j
                  k7  S )NT)
isinstance	__class__pathr
   r   
fileSystemr'   s     r!   r&   zPartition.__ne__J   s    $0yyEJJ&  L$))uzz*A  LT]]V[VdVdEd  Lhlhwhw  |A  |L  |L  iL  	Lr#   c                 *   	 | j                   }d| j                  | j                  | j
                  | j                  | j                  | j                  || j                  | j                  | j                  d
z  }|S # t        j                  $ r d }Y w xY w)Nzparted.Partition instance --
  disk: %(disk)r  fileSystem: %(fileSystem)r
  number: %(number)s  path: %(path)s  type: %(type)s
  name: %(name)s  active: %(active)s  busy: %(busy)s
  geometry: %(geometry)r  PedPartition: %(ped)r)
r   r.   r   numberr-   r
   r   activebusyped)r   r   r   r   r.   r   r0   r-   r
   r1   r2   r   )r   r   ss      r!   __str__zPartition.__str__P   s    	99D?
 iitDMMTYYiiii(8(8::  (( 	D	s   A: :BBc                 ,    t        j                  |      r%   )r   WriteOnlyProperty)r   props     r!   __writeOnlyzPartition.__writeOnlya   s    &&t,,r#   c                 H    t        | j                  j                               S z1True if the partition is active, False otherwise.)boolr   	is_activer   s    r!   r1   zPartition.actived   s     D$$..011r#   c                 H    t        | j                  j                               S r;   )r<   r   is_busyr>   s    r!   r2   zPartition.busyj   s     D$$,,.//r#   c                     | j                   S )z#The Disk this partition belongs to.)r   r>   s    r!   r   zPartition.diskp   s     zzr#   c                 6    | j                   j                         S )z4The filesystem path to this partition's device node.)r   get_pathr>   s    r!   r-   zPartition.pathu   s     ((**r#   c                 .    | j                   j                  S )zThe partition number.)r   numr>   s    r!   r0   zPartition.number{   s     ###r#   c                 B    | j                         j                  |       y)z@Set the partition name to the given string, on supported labels.N)getPedPartitionset_name)r   r   s     r!   rH   zPartition.set_name   s     	''-r#   c                 j    	 | j                   j                         S # t        j                  $ r Y yw xY w)z(The partition name, on supported labels.N)r   get_namer   r   r>   s    r!   rJ   zPartition.get_name   s4    	##,,..(( 		s    22c                     | j                   S r%   )r   r4   s    r!   <lambda>zPartition.<lambda>   s
    AMM r#   c                     t        | d|      S )Nr   setattrr4   vs     r!   rM   zPartition.<lambda>   s    =Z[@\ r#   c                     | j                   S r%   )r   rL   s    r!   rM   zPartition.<lambda>   s
    !++ r#   c                     t        | d|      S )Nr   rO   rQ   s     r!   rM   zPartition.<lambda>   s    GA{TU<V r#   c                 $    | j                  d      S )Nsystem)_Partition__writeOnlyrL   s    r!   rM   zPartition.<lambda>   s    h 7 r#   c                 8    | j                   j                  |      S r%   )r   
set_systemrQ   s     r!   rM   zPartition.<lambda>   s    ammF^F^_`Fa r#   c                 .    | j                   j                  S r%   )r   r
   rL   s    r!   rM   zPartition.<lambda>   s    amm00 r#   c                 0    t        | j                  d|      S )Nr
   )rP   r   rQ   s     r!   rM   zPartition.<lambda>   s    wq}}V\^_?` r#   c                 8    | j                   j                  |      S )zGet the value of a particular flag on the partition.  Valid flags
           are the _ped.PARTITION_* constants.  See _ped.flag_get_name() and
           _ped.flag_get_by_name() for more help working with partition flags.
        )r   get_flagr   flags     r!   getFlagzPartition.getFlag   s     ((..r#   c                 :    | j                   j                  |d      S )zSet the flag on a partition to the provided value.  On error, a
           PartitionException will be raised.  See getFlag() for more help on
           working with partition flags.   r   set_flagr^   s     r!   setFlagzPartition.setFlag       
 ((q11r#   c                 :    | j                   j                  |d      S )zUnset the flag on this Partition.  On error, a PartitionException
           will be raised.  See getFlag() for more help on working with
           partition flags.r   rc   r^   s     r!   	unsetFlagzPartition.unsetFlag   rf   r#   c                     t        j                  | j                  j                         j	                  | j
                  |j                                     S )zzGiven a constraint, return the maximum Geometry that self can be
           grown to.  Raises Partitionexception on error.r   )r   r   r   r   get_max_partition_geometryr   getPedConstraint)r   
constraints     r!   getMaxGeometryzPartition.getMaxGeometry   sS     499+?+?+A+\+\]a]m]moy  pK  pK  pM  ,N  O  	Or#   c                 8    | j                   j                  |      S )zOReturn True if flag is available on this Partition, False
           otherwise.)r   is_flag_availabler^   s     r!   isFlagAvailablezPartition.isFlagAvailable   s     11$77r#   c                     | j                   j                         j                  | j                        }|yt	        j
                  | j                   |      S )z4Return the Partition following this one on the Disk.N)r   r    )r   r   next_partitionr   r   r   )r   	partitions     r!   nextPartitionzPartition.nextPartition   sG     II((*99$:J:JK	##KKr#   c                 l    t        j                  dt               | j                  j	                  |      S )aX  Return the size of the partition 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.zuse the getLength method)warningswarnDeprecationWarningr   getSizer   units     r!   ry   zPartition.getSize   s)     	02DE}}$$T**r#   c                 8    | j                   j                  |      S )zReturn the length of the partition 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.)r   	getLengthrz   s     r!   r}   zPartition.getLength   s     }}&&t,,r#   c                     g }t         j                         D ],  }| j                  |      s|j                  t         |          . dj	                  |      S )zTReturn a comma-separated string representing the flags
           on this partition.z, )partitionFlagkeysr`   appendjoin)r   flagsr_   s      r!   getFlagsAsStringzPartition.getFlagsAsString   sO     !&&( 	2D||D!]401	2 yyr#   c                 
   |j                         }|t        j                  j                         vrt	        d|z        | j
                  j                  }| j
                  j                  j                  }| j                  j                  D ]:  }|j                  t        j                  z  r||j
                  j                  z  }: n t        j                  |t        j                  |t        j                  |         z        S )a  Return the maximum size this Partition can grow to by looking
           at contiguous freespace partitions.  The size is returned in
           the unit specified (default is megabytes).  The unit is 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.zinvalid unit %s given)lowerr   	_exponentr   SyntaxErrorr   lengthdevice
sectorSizer   
partitionsr
   PARTITION_FREESPACEmathfloorpow)r   r{   lunit	maxLengthr   rs   s         r!   getMaxAvailableSizezPartition.getMaxAvailableSize   s     

((--//5>??MM((	]]))44
-- 	I~~ : ::Y//666			 zz)dhhz6;K;KE;R&SSTTr#   c                      | j                   dd S )z*Return the device name for this Partition.   N)r-   r>   s    r!   getDeviceNodeNamezPartition.getDeviceNodeName   s    yy}r#   c                     | j                   S )zfReturn the _ped.Partition object contained in this Partition.
           For internal module use only.)r   r>   s    r!   rG   zPartition.getPedPartition   s     r#   c                 6    | j                   j                         S )z'Reset the partition's number to default)r   	reset_numr>   s    r!   resetNumberzPartition.resetNumber   s    ))++r#   )NNNNN)MB)sectors)#__name__
__module____qualname__r   r"   r)   r&   r5   rW   propertyr1   r2   r   r-   r0   rH   rJ   r.   r   rV   r
   r   r`   re   rh   rm   rp   rt   ry   r}   r   r   r   rG   r    r#   r!   r   r   $   s   r r@&L"- 2  2 0  0   +  + $ $ . . 13\]J-/VWH79abF02`aDHh'D/ / 2 2 2 2 O O
 8 8
 L L + + - -	 U0 
,r#   r   TF)r   rv   r   r   parted.decoratorsr   objectr   r   partition_flag_next__flagpartition_flag_get_name__readFlagsr   r#   r!   <module>r      s   4     %Z, Z,z 	!	!	!!	$444V<f %T%%f-F < < <V Df r#   