Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/isort/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/isort/__pycache__/main.cpython-37.pyc

B

n�]?�@s�dZddlmZmZmZmZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
ddlmZmZmZmZddlTd�e
�Zd	d
�ZGdd�de
j�Zd
d�Zdd�Zedkr�e�dS)a�  Tool for sorting imports alphabetically, and automatically separated into sections.

Copyright (C) 2013  Timothy Edmund Crosley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

�)�absolute_import�division�print_function�unicode_literalsN)�SortImports�__version__)�DEFAULT_SECTIONS�default�	from_path�should_skip�)�*a�
/#######################################################################\

     `sMMy`
     .yyyy-                                                      `
    ##soos##                                                    ./o.
          `     ``..-..`         ``...`.``         `   ```` ``-ssso```
     .s:-y-   .+osssssso/.     ./ossss+:so+:`    :+o-`/osso:+sssssssso/
     .s::y-   osss+.``.``     -ssss+-.`-ossso`   ssssso/::..::+ssss:::.
     .s::y-   /ssss+//:-.`   `ssss+     `ssss+   sssso`       :ssss`
     .s::y-   `-/+oossssso/  `ssss/      sssso   ssss/        :ssss`
     .y-/y-       ````:ssss`  ossso.    :ssss:   ssss/        :ssss.
     `/so:`    `-//::/osss+   `+ssss+-/ossso:    /sso-        `osssso/.
       \/      `-/oooo++/-      .:/++:/++/-`      ..           `://++/.


         isort your Python imports for you so you don't have to

                            VERSION {0}

\########################################################################/
c	cs�x�|D]�}tj�|�r�t||t���r2|�|�qx�tj|dd�D]|\}}}x0t|�D]$}t|||�rV|�|�|�|�qVWx>|D]6}|�	d�r�t|||�r�|�|�q�tj�
||�Vq�WqBWq|VqWdS)z6Iterate over all Python source files defined in paths.T)�topdownz.pyN)�os�path�isdirr�getcwd�append�walk�list�remove�endswith�join)	�paths�config�skippedr�dirpath�dirnames�	filenames�dirname�filename�r!�;/opt/alt/python37/lib/python3.7/site-packages/isort/main.py�iter_source_code;s 




r#c@s8eZdZdZdZgZdd�Zdd�Zdd�Zd	d
�Z	dS)�ISortCommandzoThe :class:`ISortCommand` class is used by setuptools to perform
    imports checks on registered modules.
    z-Run isort on modules registered in setuptoolscCs.t��}x t|�D]\}}t|||�qWdS)N)r	�copy�	itemsview�setattr)�selfZdefault_settings�key�valuer!r!r"�initialize_optionsZszISortCommand.initialize_optionscCs6i|_tt���}xt|�D]\}}||j|<qWdS)zGet options from config files.N)�	argumentsr
rrr&)r(Zcomputed_settingsr)r*r!r!r"�finalize_options_szISortCommand.finalize_optionsccs�|jjrj|jjpi}xT|jjD]H}|}||kr8||}nd|krT|dtjj|}|�dtjj�VqW|jjr�x|jjD]}d|Vq|WdVdS)zFind distribution packages.��.z%s.pyzsetup.pyN)�distribution�packages�package_dirrr�sep�replace�
py_modules)r(Zpackage_dirs�packageZpkg_dirr r!r!r"�distribution_filesfs
zISortCommand.distribution_filescCs�|j}d}d|d<x||��D]p}xjt�tj�|d��D]R}yt|f|�j}|rRd}Wq6t	k
r�}zt
d�t|��Wdd}~XYq6Xq6WqW|r�t
d�dS)NFT�checkz*.pyz,WARNING: Unable to parse file {0} due to {1}r)r,r7�glob�iglobrrrr�incorrectly_sorted�IOError�print�format�	file_name�exit)r(r,�wrong_sorted_filesrZpython_filer;�er!r!r"�runys*zISortCommand.runN)
�__name__�
__module__�__qualname__�__doc__�description�user_optionsr+r-r7rCr!r!r!r"r$Rsr$cCs�tjdd�}|jdddd�|jddd	d
dd�|jd
dddtd�|jddddtd�|jdddddd�|jdddddd�|jdd d!d"dd�|jd#d$d%d&dd�|jd'd(d)dd*d�|jd+d,d-dd.d�|jd/d0d1dd2d�|jd3d4d5dd6d�|jd7d8d9td:d;d<d=d>d?gd@dA�|jdBdCdDdEtd�|jdFdGdHddId�|jdJdKdLd
dMd�|jdNdOdPddQd�|jdRdSdTdUd
dVdW�|jdXdYdZd[d
d�|jd\d]d
dVd^d_d`�|jdadbdcd
ddd�|jdedcd
tjd�|jdfdgdhdid
d�|jdjdkdldmtt�dn�|jdodpdqdVd
drds�|jdtdudvd
dwd�|jdxdydzd
d{d�|jd|d}d~d
dd�|jd�d�d�d
d�d�|jd�d�d�d
d�d�|jd�d�d�d
d�d�|jd�d�d�d
d�d�|jd�d�d�d
d�d�|jd�d�d
d�d��|jd�d�d
d�d�d��|jd�d�d
d�d�d��|jd�d�d�d�dn�|jd�d�d�d�dn�|jd�d�d�d�dn�|jd�d�d
d�d�d��|jd�d�d
d�d�d��|jd�d�d
d�d�d��|jd�d�d
d�d�d��|jd�d�d�td��td�d��tt	|�
���D��}d�|k�r�dV|d~<|S)�NzFSort Python import definitions alphabetically within logical sections.)rH�filesr
z?One or more Python source files that need their imports sorted.)�nargs�helpz-yz--apply�apply�
store_truez7Tells isort to apply changes recursively without asking)�dest�actionrLz-lz--lineszO[Deprecated] The max length of an import line (used for wrapping long imports).Zline_length)rLrO�typez-wz--line-widthzBThe max length of an import line (used for wrapping long imports).z-sz--skipz�Files that sort imports should skip over. If you want to skip multiple files you should specify twice: --skip file1 --skip file2.�skipr)rLrOrPz-nsz--dont-skipz/Files that sort imports should never skip over.Znot_skipz-sgz--skip-globz)Files that sort imports should skip over.Z	skip_globz-tz--topz?Force specific imports to the top of their appropriate section.Zforce_to_topz-fz--futureZknown_future_libraryzVForce sortImports to recognize a module as part of the future compatibility libraries.z-bz	--builtinZknown_standard_libraryzOForce sortImports to recognize a module as part of the python standard library.z-oz--thirdpartyZknown_third_partyzOForce sortImports to recognize a module as being part of a third party library.z-pz	--projectZknown_first_partyzTForce sortImports to recognize a module as being part of the current python project.z-mz--multi_lineZmulti_line_outputrr����zdMulti line output (0-grid, 1-vertical, 2-hanging, 3-vert-hanging, 4-vert-grid, 5-vert-grid-grouped).)rOrQ�choicesrLz-iz--indentz:String to place for indents defaults to "    " (4 spaces).�indentz-az--add_importZadd_importszYAdds the specified import line to all files, automatically determining correct placement.z-afz--force_addsZ
force_addsz6Forces import adds even if the original file is empty.z-rz--remove_importZremove_importsz,Removes the specified import from all files.z-lsz
--length_sortz$Sort imports by their string length.Zlength_sortF)rLrOrPr	z-dz--stdoutz6Force resulting output to stdout, instead of in-place.�write_to_stdoutz-cz--check-onlyr8zrChecks the file for unsorted / unformatted imports and prints them to the command line without modifying the file.)rPr	rOrLz-slz--force-single-line-importsZforce_single_linez3Forces all from imports to appear on their own linez--force_single_line_importsz-dsz
--no-sectionsz,Put all imports into the same section bucketZno_sectionsz-sdz--section-default�default_sectionzFSets the default section for imports (by default FIRSTPARTY) options: )rOrLz-dfz--diffZ	show_diffz\Prints a diff of all the changes isort would make to a file, instead of changing it in place)rOr	rPrLz-ez
--balancedZbalanced_wrappingzEBalances wrapping to produce the most consistent line length possiblez-rcz--recursive�	recursivez:Recursively look for Python files of which to sort importsz-otz--order-by-typeZ
order_by_typez3Order imports by type in addition to alphabeticallyz-dtz--dont-order-by-typeZdont_order_by_typez?Only order imports alphabetically, do not attempt type orderingz-acz--atomicZatomiczMEnsures the output doesn't save if the resulting file contains syntax errors.z-csz--combine-starZcombine_starzWEnsures that if a star import is present, nothing else is imported from that namespace.z-caz--combine-asZcombine_as_importsz%Combines as imports on the same line.z-tcz--trailing-commaZinclude_trailing_commazIIncludes a trailing comma on multi line imports that include parentheses.z-vz	--version�show_version)rPrOz-vbz	--verbose�verbosezSShows verbose output, such as when files are skipped or when a check is successful.)rPrOrLz-qz--quiet�quietz4Shows extra quiet output, only errors are outputted.z-spz--settings-pathZ
settings_pathzTExplicitly set the settings path instead of auto determining based on file location.z-ffz--from-firstZ
from_firstzXSwitches the typical ordering preference, showing from imports first then straight ones.z-wlz
--wrap-lengthZwrap_lengthzTSpecifies how long lines that are wrapped should be, if not set line_length is used.z-fgwz--force-grid-wrapZforce_grid_wrapz?Force from imports to be grid wrapped regardless of line lengthz-fassz)--force-alphabetical-sort-within-sectionsZforce_alphabetical_sortz>Force all imports to be sorted alphabetically within a sectionz-fasz--force-alphabetical-sortz2Force all imports to be sorted as a single sectionz-fssz--force-sort-within-sectionsZforce_sort_within_sectionsz@Force imports to be sorted by module, independent of import_typez-lbtz--lines-between-typesZlines_between_types)rOrQcss|]\}}|r||fVqdS)Nr!)�.0r)r*r!r!r"�	<genexpr>�sz create_parser.<locals>.<genexpr>)�argparse�ArgumentParser�add_argument�int�str�SUPPRESSr�dictr&�vars�
parse_args)�parserr,r!r!r"�
create_parser�s�



























rkcCs�t�}|�d�rtt�dS|�dg�}|dgkrPtftj��dd�|���nz|svdg}d|d<|�dd	�svd|d
<t	t
j�|d�p�t
�
����}|�|�d	}g}|�dd	�r�t|||�}d}|�dd	�s�|�d
d	�r�tt�x�|D]x}y>t|f|�}|j}|�dd	��r|�rd}|j�r*|d7}Wq�tk
�r`}	ztd�||	��Wdd}	~	XYq�Xq�W|�rttd�|t|�7}|�r�|�dd	��s�|d�r�x|D]}
td�|
���q�Wtd�|��dS)Nr\rJ�-T)�
file_contentsrYr/r[rMFZask_to_applyrr]Z	show_logor8rz,WARNING: Unable to parse file {0} due to {1}r^zbWARNING: {0} was skipped as it's listed in 'skip' setting or matches a glob in 'skip_glob' settingzSkipped {0} files)rk�getr=�INTRO�popr�sys�stdin�readr
rr�abspathrr%�updater#r;rr<r>r@�len)r,Z
file_namesrrArZnum_skippedr?Zsort_attemptr;rBZwas_skippedr!r!r"�main�sP

 

&

rw�__main__)rG�
__future__rrrrrar9rrq�
setuptools�isortrrZisort.settingsrr	r
rZ	pie_slicer>ror#�Commandr$rkrwrDr!r!r!r"�<module>s 
7f.