
~]c        ;  @` 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 Wn e k
 r d d l Z n Xy d d l Z Wn e k
 re Z n Xy+ d d l Z e j d	 k rFd
 e _ n  Wn e k
 r`d Z n Xd Z dZ e
 j  d  Z! dZ" e d e"  e# e$ e"     Z" i5 g  d 6g  d 6g  d 6d d 6d d  6d d! 6e d" 6e d# 6d$ g d% 6d& 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 dX dY dZ 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 dx dy dz 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.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dXdYdZd[d\d]d^d_g:d`6dag db6g  dc6e" j% dd6g  de6ddh6didj6e dk6g  dl6g  dm6e dn6e do6d dp6dqdr6dqds6dqdt6dqdu6dqdv6e dw6e dx6e& dy6e dz6d{d|6d d}6d d~6e d6e d6e d6e d6e d6e d6e d6e d6e d6e d6d d6e d6e d6e d6g  d6e d6e d6e& d6e d6Z' e   d   Z( d  Z) d  Z* d  Z+ d  Z, e   d   Z- dqd Z. d S(  u"  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.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t
   namedtuple(   t	   strtobooli   (   t	   lru_cache(   t
   differencet   unionu   darwinu   linux2i   u   FUTUREu   STDLIBu
   THIRDPARTYu
   FIRSTPARTYu   LOCALFOLDERur   /(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|\.pants\.d|lib/python[0-9].[0-9]+)/u   GRIDu   VERTICALu   HANGING_INDENTu   VERTICAL_HANGING_INDENTu   VERTICAL_GRIDu   VERTICAL_GRID_GROUPEDu   VERTICAL_GRID_GROUPED_NO_COMMAu   NOQAu	   WrapModesu   force_to_topu   skipu	   skip_globiO   u   line_lengthu   wrap_lengthu   line_endingu   sectionsu   no_sectionsu
   __future__u   known_future_libraryu   ALu   BaseHTTPServeru   Bastionu   CGIHTTPServeru   Carbonu   ColorPickeru   ConfigParseru   Cookieu   DEVICEu   DocXMLRPCServeru   EasyDialogsu   FLu	   FrameWorku   GLu
   HTMLParseru   MacOSu
   MimeWriteru   MiniAEFrameu   Navu   PixMapWrapperu   Queueu   SUNAUDIODEVu   ScrolledTextu   SimpleHTTPServeru   SimpleXMLRPCServeru   SocketServeru   StringIOu   Tixu   Tkinteru   UserDictu   UserListu
   UserStringu   Wu   __builtin__u   abcu   aepacku   aetoolsu   aetypesu   aifcu   alu   anydbmu   applesingleu   argparseu   arrayu   astu   asynchatu   asynciou   asyncoreu   atexitu   audioopu   autoGILu   base64u   bdbu   binasciiu   binhexu   bisectu   bsddbu
   buildtoolsu   builtinsu   bz2u   cPickleu   cProfileu	   cStringIOu   calendaru   cdu   cfmfileu   cgiu   cgitbu   chunku   cmathu   cmdu   codeu   codecsu   codeopu   collectionsu   colorsysu   commandsu
   compileallu   compileru
   concurrentu   configparseru
   contextlibu   contextvarsu	   cookielibu   copyu   copy_regu   copyregu   cryptu   csvu   ctypesu   cursesu   dataclassesu   datetimeu   dbhashu   dbmu   decimalu   difflibu   dircacheu   disu	   distutilsu   dlu   doctestu   dumbdbmu   dummy_threadu   dummy_threadingu   emailu	   encodingsu	   ensurepipu   enumu   errnou
   exceptionsu   faulthandleru   fcntlu   filecmpu	   fileinputu   findertoolsu   flu   flpu   fmu   fnmatchu	   formatteru   fpectlu   fpformatu	   fractionsu   ftplibu	   functoolsu   future_builtinsu   gcu   gdbmu   gensuitemoduleu   getoptu   getpassu   gettextu   glu   globu   grpu   gzipu   hashlibu   heapqu   hmacu   hotshotu   htmlu   htmlentitydefsu   htmllibu   httpu   httplibu   icu   icopenu   imageopu   imaplibu   imgfileu   imghdru   impu	   importlibu   imputilu   inspectu   iou	   ipaddressu	   itertoolsu   jpegu   jsonu   keywordu   lib2to3u	   linecacheu   localeu   loggingu   lzmau	   macerrorsu
   macostoolsu   macpathu   macresourceu   mailboxu   mailcapu   marshalu   mathu   md5u   mhlibu	   mimetoolsu	   mimetypesu   mimifyu   mmapu   modulefinderu   msilibu   msvcrtu	   multifileu   multiprocessingu   mutexu   netrcu   newu   nisu   nntplibu   numbersu   operatoru   optparseu   osu   ossaudiodevu   parseru   pathlibu   pdbu   pickleu   pickletoolsu   pipesu   pkgutilu   platformu   plistlibu   popen2u   poplibu   posixu	   posixfileu   pprintu   profileu   pstatsu   ptyu   pwdu
   py_compileu   pyclbru   pydocu   queueu   quopriu   randomu   reu   readlineu   reprlibu   resourceu   rexecu   rfc822u   rlcompleteru   robotparseru   runpyu   schedu   secretsu   selectu	   selectorsu   setsu   sgmllibu   shau   shelveu   shlexu   shutilu   signalu   siteu   sitecustomizeu   smtpdu   smtplibu   sndhdru   socketu   socketserveru   spwdu   sqlite3u   sslu   statu
   statisticsu   statvfsu   stringu
   stringprepu   structu
   subprocessu   sunauu   sunaudiodevu   symbolu   symtableu   sysu	   sysconfigu   syslogu   tabnannyu   tarfileu	   telnetlibu   tempfileu   termiosu   testu   textwrapu   thisu   threadu	   threadingu   timeu   timeitu   tkinteru   tokenu   tokenizeu   traceu	   tracebacku   tracemallocu   ttku   ttyu   turtleu
   turtledemou   typesu   typingu   unicodedatau   unittestu   urllibu   urllib2u   urlparseu   usercustomizeu   uuu   uuidu   venvu   videoreaderu   warningsu   waveu   weakrefu
   webbrowseru   whichdbu   winregu   winsoundu   wsgirefu   xdrlibu   xmlu   xmlrpcu	   xmlrpclibu   zipappu   zipfileu	   zipimportu   zlibu   known_standard_libraryu   google.appengine.apiu   known_third_partyu   known_first_partyu   multi_line_outputu   forced_separateu    i   u   indentu     #u   comment_prefixu   length_sortu   add_importsu   remove_importsu   reverse_relativeu   force_single_lineu   default_sectionu    u   import_heading_futureu   import_heading_stdlibu   import_heading_thirdpartyu   import_heading_firstpartyu   import_heading_localfolderu   balanced_wrappingu   use_parenthesesu   order_by_typeu   atomiciu   lines_after_importsu   lines_between_sectionsu   lines_between_typesu   combine_as_importsu   combine_staru   keep_direct_and_as_importsu   include_trailing_commau
   from_firstu   verboseu   quietu
   force_addsu'   force_alphabetical_sort_within_sectionsu   force_alphabetical_sortu   force_grid_wrapu   force_sort_within_sectionsu	   show_diffu   ignore_whitespaceu   no_lines_beforeu   no_inline_sortu   ignore_commentsu   safety_excludesu   case_sensitivec         C` s   t  j   } d g } t r4 t j d  g | } n  t |  d d g d |  t |  d g  d |  t |  d
 | d |  t |  d g  d |  t |  d g  d |  | S(   Nu   ~/.isort.cfgu	   isort.cfgu   .editorconfigu   ~/.editorconfigu   *u   *.pyu   **.pyu   pyproject.tomlu
   tool.isortu
   .isort.cfgu   settingsu   isortu	   setup.cfgu
   tool:isortu   tox.ini(   u   *u   *.pyu   **.py(   u
   tool.isort(   u   settingsu   isort(   u   isortu
   tool:isort(   u   isortu
   tool:isort(   t   defaultt   copyt   appdirst   user_config_dirt   _update_settings_with_config(   t   patht   computed_settingst   isort_defaults(    (    s-   lib/python2.7/site-packages/isort/settings.pyt	   from_path   s    	c         C` s  d  } x< | D]4 } t j j |  } t j j |  r | } Pq q Wd } |  }	 x |	 r | t k  r t j j |	 t |   }
 t j j |
  r |
 } Pn  t j j |	  d } |	 | k r Pn  | }	 | d 7} qT W| rt j j |  rt	 | | |  n  d  S(   Ni    i   (
   t   Nonet   osR   t
   expandusert   existst   MAX_CONFIG_SEARCH_DEPTHt   joint   strt   splitt   _update_with_config_file(   R   t   nameR	   t   sectionsR   t   editor_config_filet   potential_settings_patht   expandedt   triest   current_directoryt   potential_patht   new_directory(    (    s-   lib/python2.7/site-packages/isort/settings.pyR      s(    c         C` sM  t  j j |   } t |  |  j   } | s1 d  S|  j d  rA| j d d  j   } | j d d  j   } | d k r | j d d  j   } n  | d k r d | r t |  p d	 | d
 <n/ | d k r d | r t |  p d | d
 <n  | j d d  j   } | rA| d k r+t	 d  n	 t |  | d <qAn  x| j
   D]\ } }	 | j d d  j   }
 t t j |
 d   } | t t f k r]|
 d k rt t |	   | |
 <qEt | j |
 t j |
    } | j d  rt | t |	   | |
 <qE| j d  rAt | t | t |	    | |
 <qEt | t |	   | |
 <qN| t k rt |	 t  st t |	   }	 n  |	 | |
 <qN| j d  rt t | t |	    | |
 <qN| d k r5y | |	  } Wn> t k
 r'|	 j   j   d k rt j |
  n d } n X| | |
 <qN| |	  | |
 <qNWd  S(   Nu   .editorconfigu   indent_styleu    u   indent_sizeu   tabu	   tab_widthu   spaceu    i   u   indentu   	i   u   max_line_lengthu   offu   infu   line_lengthu   not_u   sectionsu   known_u   force_grid_wrapu   falsei   (   R   R   t   dirnamet   _get_config_dataR
   t   endswitht   popt   stript   intt   floatt   itemst   replacet   lowert   typeR	   t   gett   listt   tuplet   _as_listt   sett
   startswithR   R   t	   _abspathst   boolt
   isinstanceR   t
   ValueError(   t	   file_pathR   R   t   cwdt   settingst   indent_stylet   indent_sizet   max_line_lengtht   keyt   valuet
   access_keyt   existing_value_typet   existing_datat   result(    (    s-   lib/python2.7/site-packages/isort/settings.pyR      sR    ##.!%"1c         C` sS   t  |  t  s- |  j d d  j d  }  n  t t g  |  D] } | j   ^ q:  S(   Nu   
u   ,(   R7   R0   R,   R   t   filterR6   R(   (   R@   t   item(    (    s-   lib/python2.7/site-packages/isort/settings.pyR2     s    c         C` s]   g  | D]L } | j  t j j  rM | j t j j  rM t j j |  |  n | ^ q } | S(   N(   R4   R   R   t   sepR&   R   (   R:   t   valuesR@   t   paths(    (    s-   lib/python2.7/site-packages/isort/settings.pyR5     s    Vc   
   	   C` s  i  } t  j |   } |  j d  r t r t j |  } x~ | D]E } | } x) | j d  D] } | j | i   } q_ W| j |  qC Wqd | j   k rt	 j
 d j |  |    qn |  j d  r&d } | j   }	 xB | r"| j   } d | k r| j |	  Pn  | j   }	 q Wn  t j d k rWt j d
 t  } | j |  n t j   } | j |  x6 | D]. } | j |  rw| j | j |   qwqwWWd  QX| S(   Nu   .tomlu   .u   [tool.isort]u   Found {} with [tool.isort] section, but toml package is not installed. To configure isort with {}, install with 'isort[pyproject]'.u   .editorconfigu   
u   [i   i   t   strict(   i   i   (   t   iot   openR&   t   tomlt   loadR   R/   t   updatet   readt   warningst   warnt   formatt   tellt   readlinet   seekt   syst   version_infot   configparsert   ConfigParsert   Falset	   read_filet   SafeConfigParsert   readfpt   has_sectionR+   (
   R9   R   R;   t   config_filet   configt   sectiont   config_sectionR?   t   linet   last_position(    (    s-   lib/python2.7/site-packages/isort/settings.pyR%     s@    	#c   	      C` s  t  j j | |   } | j d d  } | d d !d k rG | d } n  | r | d r d |  j d d  d } | r t  j j |  d k r d t  j j |  | } n  t j |  r t Sn  x@ | d D]4 } t j	 |  t j	 | j d d   k r t Sq Wt  j j
 |   } x< | d rU| d | d k r<t St  j j
 | d	  } qWx> | d
 D]2 } t j |  |  st j d |  |  rat SqaWt  j j |  pt  j j |  pt  j j |  st St S(   uY   Returns True if the file and/or folder should be skipped based on the passed in settings.u   \u   /i   i   u   :u   safety_excludesu   libu   skipi    u	   skip_glob(   u   lib(   R   R   R   R,   t   basenamet   safety_exclude_ret   searcht   Truet	   posixpatht   abspathR   t   fnmatcht   isfilet   isdirt   islinkR[   (	   t   filenameRa   R   t   os_patht   normalized_patht   check_excludet	   skip_patht   positiont   glob(    (    s-   lib/python2.7/site-packages/isort/settings.pyt   should_skipD  s0    *(6(   u   FUTUREu   STDLIBu
   THIRDPARTYu
   FIRSTPARTYu   LOCALFOLDER(   u   GRIDu   VERTICALu   HANGING_INDENTu   VERTICAL_HANGING_INDENTu   VERTICAL_GRIDu   VERTICAL_GRID_GROUPEDu   VERTICAL_GRID_GROUPED_NO_COMMAu   NOQAu       (/   t   __doc__t
   __future__R    R   R   R   Rl   RK   R   Rj   t   reRW   RQ   t   collectionsR   t   distutils.utilR   t	   pie_sliceR   t   utilsR   R   RY   t   ImportErrorRZ   RM   R[   R   t   systemR   R   t   DEFAULT_SECTIONSt   compileRg   t	   WrapModest   ranget   lent   GRIDRi   R	   R   R   R   R2   R5   R%   Rw   (    (    (    s-   lib/python2.7/site-packages/isort/settings.pyt   <module>   s  "

	 !




		6		
+