
    ueq                         d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	  e j                  e      Z ed      d        Z ed      d	        Zdd
ZddZy)    N)continued_indentation)fix_code)hookimpl)get_eol_charsT)tryfirstc                     |j                  d      5  t        j                  d|       t        | |      cd d d        S # 1 sw Y   y xY w)Nzformat: autopep8z$Formatting document %s with autopep8)report_progressloginfo_format)config	workspacedocumentoptionss       ?/usr/lib/python3/dist-packages/pylsp/plugins/autopep8_format.pypylsp_format_documentr      s?    		"	"#5	6 )7Bvx() ) )s	   ">Ac                     t         j                  d||       d|d   d<   |d   dxx   dz  cc<   d|d   d<   |d   d   dz   |d   d   f}t        | ||      S )	Nz0Formatting document %s in range %s with autopep8r   start	characterendline   )
line_range)r
   r   r   )r   r   r   ranger   r   s         r   pylsp_format_ranger      sw    HH?5Q #$E'N;	%LA !E%L .(1,eEl6.BCJ68
;;    c                    t        | |      }|rt        |      |d<   t        j                  d   t        j                  = t        j
                  t               d}|j                  }t        |      }|dk(  rd}|j                  dd      }t        ||      }t        j                  d   t        = t        j
                  t        j                         ||k(  rg S |r|j                  dd      }ddd	t        |j                        dd	d
|dgS )Nr   logical_lineFT
)r   r   )r   r   )r   r   )r   newText)_autopep8_configlistpycodestyle_checksr   register_checkautopep8_c_isourcer   replacer   lenlines)r   r   r   r   
replace_crr(   	eol_chars
new_sources           r   r   r   %   s   vx0G $Z 0 	N+K,M,MN|, J__Ff%ID
d+&'2J 	N+L9{@@AV	''d3
 #$!4 #HNN 3!D
 "	
	 	r   c                 h   ||j                   nd }| j                  d|      }|j                  d      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d      d	}|j                         D ci c]  \  }}|s	|| c}}S c c}}w )
Nr$   )document_pathexcludehangClosingignoremaxLineLengthselect
aggressive)r1   hang_closingr3   max_line_lengthr5   r6   )pathplugin_settingsgetitems)r   r   r9   settingsr   kvs          r   r"   r"   Q   s    $08==dD%%m4%HH<<	* ]3,,x(#<<8,,x(ll<0G %]]_2TQAqD222s   
B.%B.)N)loggingr$   autopep8r   r'   r   pylspr   pylsp._utilsr   	getLogger__name__r
   r   r   r   r"    r   r   <module>rG      sh      :   &g! 
4) ) 
4
< 
<)X3r   