
    8@d                         d dl Z d dlZd dlmZ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dS )    N)fix_codecontinued_indentation)hookimpl)get_eol_charsT)tryfirstc                     |                     d          5  t                              d|           t          | |          cd d d            S # 1 swxY w Y   d S )Nzformat: autopep8z$Formatting document %s with autopep8)report_progressloginfo_format)config	workspacedocumentoptionss       =lib/python3.11/site-packages/pylsp/plugins/autopep8_format.pypylsp_format_documentr      s    		"	"#5	6	6 ) )7BBBvx(() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s   +AAAc                     t                               d||           d|d         d<   |d         dxx         dz  cc<   d|d         d<   |d         d         dz   |d         d         dz   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      s     HH?5QQQ #$E'N;	%LA !E%L .(1,eEl6.BQ.FGJ68
;;;;    c                 2   t          | |          }|rt          |          |d<   t          j        d         t          j        = t          j        t                     d}|j        }t          |          }|dk    rd}|	                    dd          }t          ||          }t          j        d         t          = t          j        t          j                   ||k    rg S |r|	                    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   &   s9   vx00G 1 $Z 0 0 	N+K,MN|,,, J_Ff%%ID
d++&'222J 	N+L9{@AAAV	 4''d33
  a00//a@@
 

    r   c                 x   ||j         nd }|                     d|          }|                    d          |                    d          |                    d          |                    d          |                    d          |                    d          d	}d
 |                                D             S )Nr$   )document_pathexcludehangClosingignoremaxLineLengthselect
aggressive)r1   hang_closingr3   max_line_lengthr5   r6   c                     i | ]
\  }}|||S  r:   ).0kvs      r   
<dictcomp>z$_autopep8_config.<locals>.<dictcomp>^   s#    222TQ2Aq222r   )pathplugin_settingsgetitems)r   r   r?   settingsr   s        r   r"   r"   P   s    $08==dD%%m4%HHH<<	** ]33,,x((#<<88,,x((ll<00 G 32W]]__2222r   )N)loggingr$   autopep8r   r   r'   pylspr   pylsp._utilsr   	getLogger__name__r
   r   r   r   r"   r:   r   r   <module>rJ      s         D D D D D D D D       & & & & & &g!! 
4) ) ) 
4< < <' ' ' 'T3 3 3 3 3 3r   