
    7j~              	          d Z ddlmZ ddlmZ ddlmZ ddlmZ d Z	d Z
 ej                  dd	d
d       ej                  ddddd       ej                  ddded       ej                  dd      d                             Zy)z0Ensure text files have the proper line endings.
    )islice)DEVNULL)cli)normpathc                 <     t                t         fdd      S )z/Break down a collection into smaller parts
    c                  .    t        t                     S )N)tupler   itsizes   L/home/hanthebot/chat/keyboard/qmk_firmware/lib/python/qmk/cli/format/text.py<lambda>z_get_chunks.<locals>.<lambda>   s    fR./      )iterr
   s   ``r   _get_chunksr      s     
bB/44r   c                     t        | D cg c]  }t        |      j                          c}d      D ](  }t        j                  dg|      }|j
                  s( y yc c}w )z[Spawn multiple dos2unix subprocess avoiding too long commands on formatting everything
    
   dos2unixFN)r   r   as_posixr   run
returncode)filesfilechunkr   s       r   dos2unix_runr      sW     EJDhtn557JBO 77J//0	Js    Az-bz--base-branchzorigin/masterzBranch to compare to diffs to.)defaulthelpz-az--all-filesT
store_truezFormat all files.)arg_onlyactionr   r   *zFilename(s) to format.)nargsr    typer   z/Ensure text files have the proper line endings.)hiddenc           	         | j                   j                  rot        | j                   j                        }| j                   j                  r| j                  j                  ddj                  t        t        |                   n| j                   j                  rKddg} | j                  |t              }t        t        d|j                  j                  d                  }n`ddd	| j                   j                  g} | j                  |t              }t        t        d|j                  j                  d                  }|s| j                  j                  d
       yt!        |      S )z4Ensure text files have the proper line endings.
    z-Filenames passed with -a, only formatting: %s,gitzls-files)stdinN
diffz--name-onlyzGNo changed files detected. Use "qmk format-text -a" to format all filesF)argsr   list	all_fileslogwarningjoinmapstrr   r   filterstdoutsplitbase_brancherrorr   )r   r   
git_ls_cmdgit_lsgit_diff_cmdgit_diffs         r   format_textr=      s    xx~~SXX^^$88GGOOKSXXVYZ]_dVeMfg			Z(
73VD&--"5"5d";<= v}chh6J6JK377<w7VD(//"7"7"=>? _`r   N)__doc__	itertoolsr   
subprocessr   milcr   qmk.pathr   r   r   argument
subcommandr=   r   r   r   <module>rE      s       5 dO_CcddMDL_`gS4hE]^A$O P _ a er   