
    ?dL                     6    d Z ddlmZ  eddh      ZddZd Zy)	aB  Join logical lines together.

Determine how many lines can be joined into one line. For instance, we could
join these statements into one line:

  if a == 42:
    continue

like this:

  if a == 42: continue

There are a few restrictions:

  1. The lines should have been joined in the original source.
  2. The joined lines must not go over the column boundary if placed on the same
     line.
  3. They need to be very simple statements.

Note: Because we don't allow the use of a semicolon to separate statements, it
follows that there can only be at most two lines to join.
    )styledefclassc                    | d   j                   t        j                  d      z  }t        |       dk(  s|t        j                  d      kD  ryt        |       dk\  r?| d   j                   | d   j                   k\  r | d   j                   | d   j                   k7  ry| d   j                  j
                  t        v ryt        j                  d      |z
  }| d   j                  j                  |k  rm|| d   j                  j                  z  }| d   j                  j
                  dk(  rt        | |      S |r'| d   j                  j
                  d	v rt        | |      S y)
a  Determine if multiple lines can be joined into one.

  Arguments:
    lines: (list of LogicalLine) This is a splice of LogicalLines from the full
      code base.
    last_was_merged: (bool) The last line was merged.

  Returns:
    True if two consecutive lines can be joined together. In reality, this will
    only happen if two consecutive lines can be joined, due to the style guide.
  r   INDENT_WIDTH   COLUMN_LIMITF      if>   elifelse)
depthr   Getlenfirstvalue_CLASS_OR_FUNClasttotal_length_CanMergeLineIntoIfStatement)lineslast_was_merged
indent_amtlimits       :/usr/lib/python3/dist-packages/yapf/yapflib/line_joiner.pyCanMergeMultipleLinesr   *   s$    Qx~~		. 99*Z1_
UYY~%>>	%jAo%(..E!HNN:Ahnna&
 
1X^^^+
))N
#j
0%
1X]]%'	U1X]]'''EQx~~t#)%7758>>//3CC)%77 
    c                    t        | d   j                        dk(  r| d   j                  j                  ry| d   j                  | d   j                  k7  ry| d   j                  j
                  |k\  ryt        j                  d      S )a  Determine if we can merge a short if-then statement into one line.

  Two lines of an if-then statement can be merged if they were that way in the
  original source, fit on the line without going over the column limit, and are
  considered "simple" statements --- typically statements like 'pass',
  'continue', and 'break'.

  Arguments:
    lines: (list of LogicalLine) The lines we are wanting to merge.
    limit: (int) The amount of space remaining on the line.

  Returns:
    True if the lines can be merged, False otherwise.
  r   Tr   FJOIN_MULTIPLE_LINES)r   tokensr   is_multiline_stringlinenor   r   r   )r   r   s     r   r   r   U   sp     	qQ58==#D#D
1X__a'
1X]]5(	(	))r   N)F)__doc__yapf.yapflibr   	frozensetr   r   r    r   r   <module>r(      s)   . E7+,(V*r   