3
uûœ],D  ã            [  @   s\  d Z ddlmZmZmZmZ ddlZddlZddlZddl	Z	ddl
Z
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mZ yddlZW n ek
r°   ddlZY nX yddlZW n ek
rÖ   d	ZY nX yddlZejd
kròde_W n ek
�r   dZY nX dZ�dmZe
jdƒZ�dnZ ede ƒe!e"e ƒƒŽ Z g g g ddded	dgddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd€d�d‚dƒd„d…d†d‡dˆd‰dŠd‹dŒd�dŽd�d�d‘d’d“d”d•d–d—d˜d™dšd›dœd�dždŸd d¡d¢d£d¤d¥d¦d§d¨d©dªd«d¬d­d®d¯d°d±d²d³d´dµd¶d·d¸d¹dºd»d¼d½d¾d¿dÀdÁdÂdÃdÄdÅdÆdÇdÈdÉdÊdËdÌdÍdÎdÏdÐdÑdÒdÓdÔdÕdÖd×dØdÙdÚdÛdÜdÝdÞdßdàdádâdãdädådædçdèdédêdëdìdídîdïdðdñdòdódôdõdöd÷dødùdúdûdüdýdþdÿ�d �d�d�d�d�d�d�d�d�d	�d
�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d �d!�d"�d#�d$�d%�d&�d'�d(�d)�d*�d+�d,�d-�d.�d/�d0�d1�d2�d3�d4�d5�d6�d7�d8�d9�d:�d;�d<�d=�d>�d?�d@�dA�dB�dC�dD�dE�dF�dG�dH�dI�dJ�dK�dL�dM�dN�dO�dP�dQ�dR�dS�dT�dU�dV�dW�g:�dXgg e j#g �do�d[d	g g d	d	d�d\�d\�d\�d\�d\d	d	�d]d	�dpddd	d	d	d	d	d	d	d	d	d	dd	d	d	g d	d	�d]d	�d^œ5Z$eƒ �d_�d`„ ƒZ%�da�db„ Z&�dc�dd„ Z'�de�df„ Z(�dg�dh„ Z)eƒ �di�dj„ ƒZ*�dq�dk�dl„Z+dS (r  a"  isort/settings.py.

Defines how the default settings for isort should be loaded

(First from the default setting dictionary at the top of the file, then overridden by any settings
 in ~/.isort.cfg or $XDG_CONFIG_HOME/isort.cfg if there are any)

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)Ú
namedtuple)Ú	strtoboolé   )Ú	lru_cache)Ú
differenceÚunionFÚdarwinZlinux2é   ÚFUTUREÚSTDLIBÚ
THIRDPARTYÚ
FIRSTPARTYÚLOCALFOLDERzr/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|\.pants\.d|lib/python[0-9].[0-9]+)/ÚGRIDÚVERTICALÚHANGING_INDENTÚVERTICAL_HANGING_INDENTÚVERTICAL_GRIDÚVERTICAL_GRID_GROUPEDÚVERTICAL_GRID_GROUPED_NO_COMMAÚNOQAÚ	WrapModeséO   Ú
__future__ÚALÚBaseHTTPServerZBastionÚCGIHTTPServerZCarbonZColorPickerÚConfigParserÚCookieZDEVICEÚDocXMLRPCServerZEasyDialogsZFLZ	FrameWorkZGLÚ
HTMLParserÚMacOSZ
MimeWriterZMiniAEFrameZNavZPixMapWrapperÚQueueZSUNAUDIODEVÚScrolledTextÚSimpleHTTPServerÚSimpleXMLRPCServerÚSocketServerÚStringIOÚTixÚTkinterÚUserDictÚUserListÚ
UserStringÚWÚ__builtin__ÚabcZaepackZaetoolsZaetypesZaifcÚalÚanydbmZapplesingleÚargparseÚarrayÚastZasynchatZasyncioZasyncoreÚatexitZaudioopZautoGILÚbase64ZbdbÚbinasciiZbinhexÚbisectZbsddbZ
buildtoolsÚbuiltinsÚbz2ÚcPickleZcProfileÚ	cStringIOÚcalendarZcdZcfmfileÚcgiZcgitbÚchunkZcmathÚcmdÚcodeÚcodecsZcodeopÚcollectionsZcolorsysÚcommandsÚ
compileallÚcompilerZ
concurrentÚconfigparserÚ
contextlibZcontextvarsÚ	cookielibÚcopyÚcopy_regÚcopyregÚcryptÚcsvÚctypesZcursesZdataclassesÚdatetimeÚdbhashÚdbmÚdecimalÚdifflibZdircacheÚdisÚ	distutilsÚdlÚdoctestÚdumbdbmÚdummy_threadÚdummy_threadingÚemailÚ	encodingsZ	ensurepipÚenumÚerrnoÚ
exceptionsÚfaulthandlerÚfcntlZfilecmpZ	fileinputZfindertoolsÚflZflpZfmÚfnmatchÚ	formatterZfpectlZfpformatZ	fractionsÚftplibÚ	functoolsZfuture_builtinsÚgcÚgdbmZgensuitemoduleÚgetoptÚgetpassÚgettextÚglÚglobÚgrpÚgzipÚhashlibÚheapqÚhmacZhotshotÚhtmlÚhtmlentitydefsZhtmllibÚhttpÚhttplibZicZicopenZimageopZimaplibZimgfileZimghdrÚimpÚ	importlibZimputilÚinspectÚioÚ	ipaddressÚ	itertoolsZjpegÚjsonÚkeywordZlib2to3Ú	linecacheÚlocaleÚloggingÚlzmaZ	macerrorsZ
macostoolsZmacpathZmacresourceZmailboxZmailcapÚmarshalÚmathÚmd5ZmhlibZ	mimetoolsÚ	mimetypesZmimifyZmmapZmodulefinderZmsilibÚmsvcrtZ	multifileÚmultiprocessingÚmutexÚnetrcÚnewZnisZnntplibÚnumbersÚoperatorÚoptparseÚosZossaudiodevÚparserZpathlibÚpdbÚpickleZpickletoolsZpipesÚpkgutilÚplatformÚplistlibZpopen2ZpoplibÚposixZ	posixfileÚpprintZprofileZpstatsZptyÚpwdÚ
py_compileZpyclbrÚpydocÚqueueÚquopriÚrandomÚreÚreadlineÚreprlibÚresourceZrexecZrfc822ÚrlcompleterÚrobotparserZrunpyZschedZsecretsÚselectÚ	selectorsZsetsZsgmllibZshaZshelveÚshlexÚshutilÚsignalÚsiteÚsitecustomizeZsmtpdÚsmtplibZsndhdrÚsocketÚsocketserverZspwdZsqlite3ÚsslÚstatZ
statisticsÚstatvfsÚstringÚ
stringprepÚstructÚ
subprocessZsunauZsunaudiodevÚsymbolZsymtableÚsysÚ	sysconfigÚsyslogZtabnannyÚtarfileZ	telnetlibÚtempfileÚtermiosÚtestÚtextwrapÚthisÚthreadÚ	threadingÚtimeZtimeitÚtkinterÚtokenÚtokenizeÚtraceÚ	tracebackÚtracemallocÚttkÚttyZturtleZ
turtledemoÚtypesÚtypingÚunicodedataZunittestÚurllibÚurllib2ÚurlparseÚusercustomizeÚuuÚuuidÚvenvZvideoreaderÚwarningsZwaveÚweakrefZ
webbrowserÚwhichdbÚwinregZwinsoundÚwsgirefZxdrlibÚxmlZxmlrpcÚ	xmlrpclibZzipappÚzipfileÚ	zipimportÚzlibzgoogle.appengine.apiú é   z  #Ú T)5Zforce_to_topÚskipÚ	skip_globÚline_lengthZwrap_lengthZline_endingÚsectionsZno_sectionsZknown_future_libraryZknown_standard_libraryZknown_third_partyZknown_first_partyZmulti_line_outputZforced_separateÚindentZcomment_prefixZlength_sortZadd_importsZremove_importsZreverse_relativeZforce_single_lineÚdefault_sectionZimport_heading_futureZimport_heading_stdlibZimport_heading_thirdpartyZimport_heading_firstpartyZimport_heading_localfolderZbalanced_wrappingZuse_parenthesesZorder_by_typeZatomicZlines_after_importsZlines_between_sectionsZlines_between_typesZcombine_as_importsZcombine_starZkeep_direct_and_as_importsZinclude_trailing_commaZ
from_firstÚverboseÚquietZ
force_addsZ'force_alphabetical_sort_within_sectionsZforce_alphabetical_sortÚforce_grid_wrapZforce_sort_within_sectionsZ	show_diffZignore_whitespaceZno_lines_beforeZno_inline_sortÚignore_commentsÚsafety_excludesZcase_sensitivec             C   sx   t jƒ }dg}tr"tjdƒg| }t| ddgd|ƒ t| dg d|ƒ t| d
|d|ƒ t| dg d|ƒ t| dg d|ƒ |S )Nz~/.isort.cfgz	isort.cfgz.editorconfigz~/.editorconfigÚ*ú*.pyú**.pyzpyproject.tomlú
tool.isortz
.isort.cfgÚsettingsÚisortz	setup.cfgú
tool:isortztox.ini)rñ   rò   ró   )rô   )rõ   rö   )rö   r÷   )rö   r÷   )ÚdefaultrN   ÚappdirsÚuser_config_dirÚ_update_settings_with_config)ÚpathÚcomputed_settingsZisort_defaults© rþ   ú//tmp/pip-build-fn42xldr/isort/isort/settings.pyÚ	from_path©   s    r   c             C   s´   d }x*|D ]"}t jj|ƒ}t jj|ƒr
|}P q
W d}| }	xZ|	r’|tk r’t jj|	t|ƒƒ}
t jj|
ƒrj|
}P t jj|	ƒd }|	|kr„P |}	|d7 }q:W |r°t jj|ƒr°t|||ƒ d S )Nr   r   )	r”   rü   Ú
expanduserÚexistsÚMAX_CONFIG_SEARCH_DEPTHÚjoinÚstrÚsplitÚ_update_with_config_file)rü   Únamerø   ré   rý   Zeditor_config_fileZpotential_settings_pathÚexpandedÚtriesÚcurrent_directoryZpotential_pathZnew_directoryrþ   rþ   rÿ   rû   ¸   s(    
rû   c             C   sb  t jj| ƒ}t| |ƒjƒ }|s"d S | jdƒrÖ|jddƒjƒ }|jddƒjƒ }|dkrd|jddƒjƒ }|dkr†d|rzt|ƒp|d	 |d
< n |dkr¦d|rœt|ƒpžd |d
< |jddƒjƒ }|rÖ|dkrÊt	dƒnt|ƒ|d< �x„|j
ƒ D �]v\}}	|jddƒjƒ }
ttj|
dƒƒ}|ttfk�r¦|
dk�r6tt|	ƒƒ||
< nnt|j|
tj|
ƒƒƒ}|jdƒ�rlt|t|	ƒƒ||
< n8|jdƒ�r’t|t|t|	ƒƒƒ||
< nt|t|	ƒƒ||
< qâ|tk�rÒt|	tƒ�sÈtt|	ƒƒ}	|	||
< qâ|jdƒ�rött|t|	ƒƒƒ||
< qâ|dk�rNy||	ƒ}W n6 tk
�rB   |	jƒ jƒ dk�r:tj|
ƒnd}Y nX |||
< qâ||	ƒ||
< qâW d S )Nz.editorconfigÚindent_stylerå   Úindent_sizeÚtabZ	tab_widthÚspacerã   rä   rê   ú	r   Úmax_line_lengthÚoffÚinfrè   Únot_ré   Zknown_rî   Úfalseé   )r”   rü   ÚdirnameÚ_get_config_datarN   ÚendswithÚpopÚstripÚintÚfloatÚitemsÚreplaceÚlowerÚtyperø   ÚgetÚlistÚtupleÚ_as_listÚsetÚ
startswithr
   r   Ú	_abspathsÚboolÚ
isinstancer   Ú
ValueError)Ú	file_pathré   rý   Úcwdrõ   r  r  r  ÚkeyÚvalueZ
access_keyZexisting_value_typeZexisting_dataÚresultrþ   rþ   rÿ   r  Ò   sR    




&
r  c             C   s0   t | tƒs| jddƒjdƒ} ttdd„ | D ƒƒS )NÚ
ú,c             S   s   g | ]}|j ƒ ‘qS rþ   )r  )Ú.0Úitemrþ   rþ   rÿ   ú
<listcomp>  s    z_as_list.<locals>.<listcomp>)r*  r#  r  r  Úfilterr)  )r/  rþ   rþ   rÿ   r%    s    
r%  c                s   ‡ fdd„|D ƒ}|S )Nc                s<   g | ]4}|j tjjƒ r4|jtjjƒr4tjjˆ |ƒn|‘qS rþ   )r'  r”   rü   Úsepr  r  )r3  r/  )r-  rþ   rÿ   r5    s   z_abspaths.<locals>.<listcomp>rþ   )r-  ÚvaluesÚpathsrþ   )r-  rÿ   r(    s    
r(  c       
      C   s:  i }t j| ƒ�� }| jdƒrˆtrhtj|ƒ}xZ|D ]2}|}x|jdƒD ]}|j|i ƒ}qDW |j|ƒ q0W nd|jƒ kr†t	j
dj| | ƒƒ n¤| jdƒrÌd}|jƒ }	x,|rÊ|jƒ }d|krÀ|j|	ƒ P |jƒ }	q W tjdkrîtjd
d�}|j|ƒ ntjƒ }|j|ƒ x*|D ]"}|j|ƒ�r|j|j|ƒƒ �qW W d Q R X |S )Nz.tomlÚ.z[tool.isort]zƒFound {} with [tool.isort] section, but toml package is not installed. To configure isort with {}, install with 'isort[pyproject]'.z.editorconfigr1  ú[é   r  F)Ústrict)r<  r  )r   Úopenr  ÚtomlÚloadr  r"  ÚupdateÚreadrÙ   ÚwarnÚformatÚtellr¤   Úseekr»   Úversion_inforK   r!   Ú	read_fileÚSafeConfigParserÚreadfpÚhas_sectionr  )
r,  ré   rõ   Úconfig_fileÚconfigÚsectionZconfig_sectionr.  ÚlineZlast_positionrþ   rþ   rÿ   r    s@    








 r  c       	      C   sf  t jj|| ƒ}|jddƒ}|dd… dkr6|dd… }|rŒ|d rŒd| jddƒ d }|r~t jj|ƒdkr~dt jj|ƒ | }tj|ƒrŒd	S x0|d
 D ]$}tj|ƒtj|jddƒƒkr–d	S q–W t jj	| ƒ}x0|d rú|d |d
 krèd	S t jj	|d ƒ}qÌW x6|d D ]*}t
j
| |ƒ�s*t
j
d|  |ƒ�rd	S �qW t jj|ƒ�pZt jj|ƒ�pZt jj|ƒ�sbd	S dS )zYReturns True if the file and/or folder should be skipped based on the passed in settings.ú\ú/r   r  ú:Nrð   ÚlibTræ   r   rç   F)rS  )r”   rü   r  r  ÚbasenameÚsafety_exclude_reÚsearchÚ	posixpathÚabspathr  rh   ÚisfileÚisdirÚislink)	ÚfilenamerM  rü   Zos_pathZnormalized_pathZcheck_excludeZ	skip_pathÚpositionrr   rþ   rþ   rÿ   Úshould_skipD  s0    

 
*r^  )r   r   r   r   r   )r   r   r   r   r   r   r   r   z    éÿÿÿÿ)rå   ),Ú__doc__r   r   r   r   r   rh   r   r”   rW  r£   r»   rÙ   rG   r   Údistutils.utilr   Z	pie_slicer	   Úutilsr
   r   rK   ÚImportErrorr!   r?  rù   Úsystemr  ZDEFAULT_SECTIONSÚcompilerU  r   ÚrangeÚlenr   rø   r   rû   r  r%  r(  r  r^  rþ   rþ   rþ   rÿ   Ú<module>   s  



 
    
6
+