
    XZs                     6    d dl Z d dlZd dlmZ  G d de      Zy)    N)localeCc                       e Zd ZdZed        Z ed d       Z ed d       Zd Z	d Z
d	 Zed
        Zed        Zed        Zed        Zed        Zd Zy)	Alignmenta  Alignment()

       An Alignment object describes constraints on how sectors and Geometry
       objects are aligned.  Being aligned means that the sector be located at
       a specific sector multiple on a device, or that a geometry must start
       and end at sectors at those specific multiples.  Most methods on this
       object raise ArithmeticError if calculating alignments fails.c                     d|v r|j                  d      | _        yd|v r>d|v r:t        j                  |j                  d      |j                  d            | _        yt	        j
                  d      )zOCreate a new Alignment object from the sectors offset and
           grainSize.PedAlignmentoffset	grainSizez-no offset+grainSize or PedAlignment specifiedN)get_Alignment__alignment_pedr   partedAlignmentException)selfargskwargss      2/usr/lib/python3/dist-packages/parted/alignment.py__init__zAlignment.__init__'   si     V#%zz.9DK6$9#~~fjj.B.4jj.E GD ++,[\\    c                 .    | j                   j                  S N)r   r   ss    r   <lambda>zAlignment.<lambda>3   s     4 4 r   c                 0    t        | j                  d|      S )Nr   setattrr   r   vs     r   r   zAlignment.<lambda>3   s    71==ZbdeCf r   c                 .    | j                   j                  S r   )r   
grain_sizer   s    r   r   zAlignment.<lambda>4   s    1==#;#; r   c                 0    t        | j                  d|      S )Nr    r   r   s     r   r   zAlignment.<lambda>4   s    'RSR_R_amopJq r   c                 &    | j                  |       S r   )__ne__r   others     r   __eq__zAlignment.__eq__6   s    ;;u%%%r   c                     t        | |j                        sy| j                  |j                  k7  xs | j                  |j                  k7  S )NT)
isinstance	__class__r   r	   r$   s     r   r#   zAlignment.__ne__9   s8    $0{{ell*Odnn.OOr   c                 T    d| j                   | j                  | j                  dz  }|S )Nzcparted.Alignment instance --
  offset: %(offset)s  grainSize: %(grainSize)s
  PedAlignment: %(ped)r)r   r	   ped)r   r	   r   )r   r   s     r   __str__zAlignment.__str__?   s2    ' $..%%''
 r   c                 |    t        j                  | j                  j                  |j	                                     S )a#  Create and return a new Alignment that describes the intersection of
           self and alignment b.  A sector will satisfy the new alignment iff
           it satisfies both of the original alignments.  Whether a sector
           satisfies a given alignment is determined by is_aligned().)r   )r   r   r   	intersectgetPedAlignment)r   bs     r   r.   zAlignment.intersectG   s/     T-=-=-G-GHYHYH[-\]]r   c                 V    | j                   j                  |j                         |      S )a"  Return the closest sector to the provided sector that lies inside
           geom and satisfies the alignment constraint self.  This method
           prefers, but does not guarantee, that the result is beyond sector.
           If no such sector can be found, an ArithmeticError is raised.)r   align_upgetPedGeometryr   geomsectors      r   alignUpzAlignment.alignUpO   s&     (()<)<)>GGr   c                 V    | j                   j                  |j                         |      S )a!  Return the closest sector to the provided sector that lies inside
           geom and satisfies the alignment constraint self.  This method
           prefers, but does not guarantee, that the result is below sector.
           If no such sector can be found, an ArithmeticError is raised.)r   
align_downr3   r4   s      r   	alignDownzAlignment.alignDownW   s&     **4+>+>+@&IIr   c                 V    | j                   j                  |j                         |      S )zReturn the closest sector to the input sector that lies inside
           geom and satisfies the alignment constraint self.  If no such sector
           can be found, an ArithmeticError is raised.)r   align_nearestr3   r4   s      r   alignNearestzAlignment.alignNearest_   s&    
 --d.A.A.CVLLr   c                     |st        d      |t        d      | j                  j                  |j                         |      S )zaDetermine whether sector lies inside geom and satisfies the
           alignment constraint self.z!missing parted.Geometry parameterzmissing sector parameter)	TypeErrorr   
is_alignedr3   r4   s      r   	isAlignedzAlignment.isAlignedf   sF     ?@@>677**4+>+>+@&IIr   c                     | j                   S )zfReturn the _ped.Alignment object contained in this Alignment.
           For internal module use only.)r   )r   s    r   r/   zAlignment.getPedAlignmentr   s     r   N)__name__
__module____qualname____doc__r   r   propertyr   r	   r&   r#   r,   r.   r7   r:   r=   rA   r/    r   r   r   r      s    H 	] 	] 46fgF;=qrI&P ^ ^ H H J J M M 	J 	J r   r   )r   r   parted.decoratorsr   objectr   rH   r   r   <module>rK      s   4   %V  V r   