
    Y\                     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d Zd Z ed d       Z	 ed d       Z
 ed	 d
       Z ed d       Z ed d       Z ed d       Zd Zed        Zed        Zed        Zed        Zd Zy)
Constrainta  Constraint()

       A Constraint object describes a set of restrictions on other pyparted
       operations.  Constraints can restrict the location and alignment of the
       start and end of a partition, and its minimum and maximum size.  Most
       constraint operations can raise CreateException if creating temporary
       objects fails, or ArithmeticError if an error occurs during
       calculations.c                    d|v r|j                  d      | _        yd|v r^d|v rZ|j                  d      j                         }|j                  d      j                         }t        j                  ||      | _        yd|v r:|j                  d      j                         }t        j
                  |      | _        yd|v r:|j                  d      j                         }t        j                  |      | _        yd|v r:|j                  d      j                         }t        j                  |      | _        yd|v r:|j                  d      j                         }t        j                  |      | _        yd|v rd|v rd|v rd	|v rd
|v rd|v r|j                  d      j                         }|j                  d      j                         }|j                  d      j                         }	|j                  d	      j                         }
|j                  d
      }|j                  d      }t        j                  |||	|
||      | _        yt        j                  d      )a  Create a new Constraint object.  There are many different ways to
           create a Constraint, all depending on the parameters passed to
           __init__.  If minGeom and maxGeom are supplied, the constraint will
           be created to satisfy both.  If only one of minGeom or maxGeom are
           supplied, the constraint is only guaranteed to solve the given
           parameter.  If exactGeom is given, the constraint will only be
           satisfied by the given geometry.  If device is given, any region
           on that device will satisfy the constraint.

           If none of the previously mentioned parameters are supplied, all of
           startAlign, EndAlign, startRange, endRange, minSize, and maxSize
           must be given.PedConstraintminGeommaxGeom	exactGeomdevice
startAlignendAlign
startRangeendRangeminSizemaxSizez!missing initialization parametersN)get_Constraint__constraintgetPedGeometry_pedconstraint_new_from_min_maxconstraint_new_from_minconstraint_new_from_maxconstraint_exactgetPedDeviceconstraint_anygetPedAlignmentr   partedConstraintException)selfargskwargsmingmaxgexactdevstartaendastartrendrminsmaxss                3/usr/lib/python3/dist-packages/parted/constraint.py__init__zConstraint.__init__(   s    f$ &

? ;D& Y&%8::i(779D::i(779D $ @ @t LD& ::i(779D $ < <T BD& ::i(779D $ < <T BDF"JJ{+::<E $ 5 5e <D**X&335C $ 3 3C 8DV#
f(<V#
f(<& Y&%8ZZ-==?F::j)99;DZZ-<<>F::j)88:D::i(D::i(D $fd04d!<D ,,-PQQ    c                 &    | j                  |       S N)__ne__)r   others     r,   __eq__zConstraint.__eq__V   s    ;;u%%%r.   c                    t        |       t        |      k(  ryt        | |j                        sy| j                         }|j                         }| j                  |j                  k7  xs | j
                  |j
                  k7  xsj |j                  |j                  k7  xsO |j                  |j                  k7  xs4 |j                  |j                  k7  xs |j                  |j                  k7  S )NFT)
hash
isinstance	__class__getPedConstraintr   r   start_align	end_alignstart_range	end_range)r   r2   c1c2s       r,   r1   zConstraint.__ne__Y   s    :e$$0""$##%||u}}, 0<<5==00>>R^^30 <<2<</0 >>R^^3	0
 <<2<</	0r.   c                 V    t        j                  | j                  j                        S N)PedAlignment)r   	Alignmentr   r9   ss    r,   <lambda>zConstraint.<lambda>k   s    f&&ANN4N4NO r.   c                 L    t        | j                  d|j                               S )Nr9   setattrr   r   rD   vs     r,   rE   zConstraint.<lambda>l   s    @Q@Q@ST r.   c                 V    t        j                  | j                  j                        S r@   )r   rB   r   r:   rC   s    r,   rE   zConstraint.<lambda>o   s    f&&ANN4L4LM r.   c                 L    t        | j                  d|j                               S )Nr:   rG   rI   s     r,   rE   zConstraint.<lambda>p   s    a>O>O>QR r.   c                 V    t        j                  | j                  j                        S NPedGeometry)r   Geometryr   r;   rC   s    r,   rE   zConstraint.<lambda>s   s    foo!..2L2LM r.   c                 L    t        | j                  d|j                               S )Nr;   rH   r   r   rI   s     r,   rE   zConstraint.<lambda>t   s    @P@P@RS r.   c                 V    t        j                  | j                  j                        S rN   )r   rQ   r   r<   rC   s    r,   rE   zConstraint.<lambda>w   s    foo!..2J2JK r.   c                 L    t        | j                  d|j                               S )Nr<   rS   rI   s     r,   rE   zConstraint.<lambda>x   s    a>N>N>PQ r.   c                 .    | j                   j                  S r0   )r   min_sizerC   s    r,   rE   zConstraint.<lambda>{       ann-- r.   c                 0    t        | j                  d|      S )NrW   rH   r   rI   s     r,   rE   zConstraint.<lambda>|       Q? r.   c                 .    | j                   j                  S r0   )r   max_sizerC   s    r,   rE   zConstraint.<lambda>   rX   r.   c                 0    t        | j                  d|      S )Nr]   rZ   rI   s     r,   rE   zConstraint.<lambda>   r[   r.   c           	          d| j                   | j                  | j                  | j                  | j                  | j
                  | j                  dz  }|S )Nzparted.Constraint instance --
  startAlign: %(startAlign)r  endAlign: %(endAlign)r
  startRange: %(startRange)r  endRange: %(endRange)r
  minSize: %(minSize)s  maxSize: %(maxSize)s
  PedConstraint: %(ped)r)r   r   r   r   r   r   ped)r   r   r   r   r   r   r   )r   rD   s     r,   __str__zConstraint.__str__   sL    (
 !OO OO$,,&&(( r.   c                 |    t        j                  | j                  j                  |j	                                     S )zReturn a new constraint that is the intersection of self and the
           provided constraint b.  The returned constraint will therefore be
           more restrictive than either input as it will have to satisfy
           both.)r   )r   r   r   	intersectr8   )r   bs     r,   rc   zConstraint.intersect   s/       t/@/@/J/J1K]K]K_/`aar.   c                 ^    t        j                  | j                  j                               S )zReturn a new geometry that is the largest region satisfying self.
           There may be more than one solution, and there are no guarantees as
           to which solution will be returned.rO   )r   rQ   r   	solve_maxr   s    r,   solveMaxzConstraint.solveMax   s"    
 4+<+<+F+F+HIIr.   c                 |    t        j                  | j                  j                  |j	                                     S )zReturn a new geometry that is the nearest region to geom that
           satisfies self.  This function does not guarantee any specific
           meaning of 'nearest'.rO   )r   rQ   r   solve_nearestr   r   geoms     r,   solveNearestzConstraint.solveNearest   s-    
 4+<+<+J+J4K^K^K`+abbr.   c                 T    | j                   j                  |j                               S )z"Does geom satisfy this constraint?)r   is_solutionr   rk   s     r,   
isSolutionzConstraint.isSolution   s$       ,,T-@-@-BCCr.   c                     | j                   S )zhReturn the _ped.Constraint object contained in this Constraint.
           For internal module use only.)r   rg   s    r,   r8   zConstraint.getPedConstraint   s        r.   N)__name__
__module____qualname____doc__r   r-   r3   r1   propertyr   r   r   r   r   r   ra   rc   rh   rm   rp   r8    r.   r,   r   r      s     +R +RZ&0" OTVJ MRTH MSUJ KQSH -?AG -?AG
 b b J J c c D D!r.   r   )r   r   parted.decoratorsr   objectr   rw   r.   r,   <module>rz      s   4   %M! M!r.   