ó
¦xxTc           @€  sÒ  d  Z  d d l m Z d 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 m Z m Z d d l m Z d d	 l m Z m Z d d
 l m Z d d l m Z e d „ Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z  e j! d d f k  r[d d l" Z" e" j# Z$ d „  Z% d „  Z& n e# Z$ e  Z% e  Z& d „  Z' d e f d „  ƒ  YZ( d e) f d „  ƒ  YZ* d e f d „  ƒ  YZ+ d e* f d „  ƒ  YZ, d S(    sÛ   Refactoring framework.

Used as a main program, this can refactor any number of files and/or
recursively descend down directories.  Imported as a module, this
provides infrastructure to write your own refactoring tool.
iÿÿÿÿ(   t   with_statements#   Guido van Rossum <guido@python.org>N(   t   chaini   (   t   drivert   tokenizet   token(   t	   find_root(   t   pytreet   pygram(   t	   btm_utils(   t   btm_matcherc         C€  sœ   t  |  g  g  d g ƒ } t j j | j ƒ } g  } xb t t j | ƒ ƒ D]K } | j d ƒ rI | j d ƒ rI | r€ | d } n  | j	 | d  ƒ qI qI W| S(   sE   Return a sorted list of all available fix names in the given package.t   *t   fix_s   .pyi   iýÿÿÿ(
   t
   __import__t   ost   patht   dirnamet   __file__t   sortedt   listdirt
   startswitht   endswitht   append(   t	   fixer_pkgt   remove_prefixt   pkgt	   fixer_dirt	   fix_namest   name(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   get_all_fix_names!   s    t
   _EveryNodec           B€  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR   .   s   c         C€  sß   t  |  t j t j f ƒ rC |  j d k r3 t ‚ n  t |  j g ƒ St  |  t j ƒ rt |  j	 rk t
 |  j	 ƒ St ‚ n  t  |  t j ƒ rË t ƒ  } x5 |  j	 D]* } x! | D] } | j t
 | ƒ ƒ q¦ Wq™ W| St d |  ƒ ‚ d S(   sf    Accepts a pytree Pattern Node and returns a set
        of the pattern types which will match first. s$   Oh no! I don't understand pattern %sN(   t
   isinstanceR   t   NodePatternt   LeafPatternt   typet   NoneR   t   sett   NegatedPatternt   contentt   _get_head_typest   WildcardPatternt   updatet	   Exception(   t   patt   rt   pt   x(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR(   2   s    				c         C€  s  t  j t ƒ } g  } x£ |  D]› } | j r„ y t | j ƒ } Wn t k
 r^ | j | ƒ q· XxU | D] } | | j | ƒ qf Wq | j d k	 rª | | j j | ƒ q | j | ƒ q Wx: t	 t
 j j j ƒ  t
 j j ƒ D] } | | j | ƒ qÝ Wt | ƒ S(   s^    Accepts a list of fixers and returns a dictionary
        of head node type --> fixer list.  N(   t   collectionst   defaultdictt   listt   patternR(   R   R   t   _accept_typeR$   R   R   t   python_grammart   symbol2numbert
   itervaluest   tokenst   extendt   dict(   t
   fixer_listt
   head_nodest   everyt   fixert   headst	   node_type(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   _get_headnode_dictN   s"    	c         C€  s(   g  t  |  t ƒ D] } |  d | ^ q S(   sN   
    Return the fully qualified names for fixers in the package pkg_name.
    t   .(   R   t   False(   t   pkg_namet   fix_name(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   get_fixers_from_packageg   s    c         C€  s   |  S(   N(    (   t   obj(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt	   _identityn   s    i   i    c         C€  s   |  j  d d ƒ S(   Nu   
u   
(   t   replace(   t   input(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   _from_system_newlinesu   s    c         C€  s*   t  j d k r" |  j d t  j ƒ S|  Sd  S(   Ns   
u   
(   R   t   linesepRI   (   RJ   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   _to_system_newlinesw   s    c         €  sà  t  } t j t j |  ƒ j ƒ ‰  ‡  f d †  } t t j t j t j	 f ƒ } t
 ƒ  } ykxdt rÀ| ƒ  \ } } | | k r„ q] q] | t j k r¦ | r� Pn  t } q] | t j k r¼| d k r¼| ƒ  \ } } | t j k së | d k rï Pn  | ƒ  \ } } | t j k s| d k rPn  | ƒ  \ } } | t j k rY| d k rY| ƒ  \ } } n  xa | t j k r¸| j | ƒ | ƒ  \ } } | t j k s¢| d k r¦Pn  | ƒ  \ } } q\Wq] Pq] WWn t k
 rÕn Xt | ƒ S(   Nc          €  s   ˆ  j  ƒ  }  |  d |  d f S(   Ni    i   (   t   next(   t   tok(   t   gen(    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   advance…   s    u   fromu
   __future__u   importu   (u   ,(   RC   R   t   generate_tokenst   StringIOt   readlinet	   frozensetR   t   NEWLINEt   NLt   COMMENTR%   t   Truet   STRINGt   NAMEt   OPt   addt   StopIteration(   t   sourcet   have_docstringRQ   t   ignoret   featurest   tpt   value(    (   RP   s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   _detect_future_features‚   sD    				t
   FixerErrorc           B€  s   e  Z d  Z RS(   s   A fixer could not be loaded.(   R   R   t   __doc__(    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRf   ª   s   t   RefactoringToolc           B€  s!  e  Z i e d  6e d 6Z d Z d Z d d d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z e e d
 „ Z e e d „ Z d „  Z e e d „ Z d „  Z e d „ Z d „  Z d „  Z d e d d „ Z d d „ Z d Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   t   print_functiont   write_unchanged_filest   FixR   c         C€  sÄ  | |  _  | p g  |  _ |  j j ƒ  |  _ | d k	 rI |  j j | ƒ n  |  j d re t j |  _	 n t j
 |  _	 |  j j d ƒ |  _ g  |  _ t j d ƒ |  _ g  |  _ t |  _ t j |  j	 d t j d |  j ƒ|  _ |  j ƒ  \ |  _ |  _ g  |  _ t j ƒ  |  _ g  |  _ g  |  _  x} t! |  j |  j ƒ D]f } | j" rT|  j j# | ƒ q2| |  j k rv|  j j$ | ƒ q2| |  j k r2|  j  j$ | ƒ q2q2Wt% |  j ƒ |  _& t% |  j  ƒ |  _' d S(   sÒ   Initializer.

        Args:
            fixer_names: a list of fixers to import
            options: an dict with configuration.
            explicit: a list of fixers to run even if they are explicit.
        Ri   Rj   Rh   t   convertt   loggerN((   t   fixerst   explicitt   _default_optionst   copyt   optionsR$   R*   R   t!   python_grammar_no_print_statementt   grammarR5   t   getRj   t   errorst   loggingt	   getLoggerRm   t	   fixer_logRC   t   wroteR   t   DriverR   Rl   t
   get_fixerst	   pre_ordert
   post_ordert   filest   bmt   BottomMatchert   BMt   bmi_pre_ordert   bmi_post_orderR   t   BM_compatiblet	   add_fixerR   RA   t   bmi_pre_order_headst   bmi_post_order_heads(   t   selft   fixer_namesRr   Ro   R>   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   __init__¶   s<    									c         C€  sÝ  g  } g  } x•|  j  D]Š} t | i  i  d g ƒ } | j d d ƒ d } | j |  j ƒ rr | t |  j ƒ } n  | j d ƒ } |  j d j g  | D] } | j	 ƒ  ^ q” ƒ } y t
 | | ƒ }	 Wn' t k
 rì t d | | f ƒ ‚ n X|	 |  j |  j ƒ }
 |
 j r?|  j t k	 r?| |  j k r?|  j d | ƒ q n  |  j d	 | ƒ |
 j d
 k rn| j |
 ƒ q |
 j d k r�| j |
 ƒ q t d |
 j ƒ ‚ q Wt j d ƒ } | j d | ƒ | j d | ƒ | | f S(   s  Inspects the options to load the requested patterns and handlers.

        Returns:
          (pre_order, post_order), where pre_order is the list of fixers that
          want a pre-order AST traversal, and post_order is the list that want
          post-order traversal.
        R
   RB   i   iÿÿÿÿt   _t    s   Can't find %s.%ss   Skipping implicit fixer: %ss   Adding transformation: %st   pret   posts   Illegal fixer order: %rt	   run_ordert   key(   Rn   R   t   rsplitR   t   FILE_PREFIXt   lent   splitt   CLASS_PREFIXt   joint   titlet   getattrt   AttributeErrorRf   Rr   Ry   Ro   RY   t   log_messaget	   log_debugt   orderR   t   operatort
   attrgettert   sort(   R‰   t   pre_order_fixerst   post_order_fixerst   fix_mod_patht   modRE   t   partsR.   t
   class_namet	   fix_classR>   t   key_func(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR|   ê   s8    /c         O€  s   ‚  d S(   s   Called when an error occurs.N(    (   R‰   t   msgt   argst   kwds(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt	   log_error  s    c         G€  s'   | r | | } n  |  j  j | ƒ d S(   s   Hook to log a message.N(   Rm   t   info(   R‰   R©   Rª   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR›     s    c         G€  s'   | r | | } n  |  j  j | ƒ d  S(   N(   Rm   t   debug(   R‰   R©   Rª   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRœ     s    c         C€  s   d S(   sT   Called with the old version, new version, and filename of a
        refactored file.N(    (   R‰   t   old_textt   new_textt   filenamet   equal(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   print_output!  s    c         C€  sP   xI | D]A } t  j j | ƒ r5 |  j | | | ƒ q |  j | | | ƒ q Wd S(   s)   Refactor a list of files and directories.N(   R   R   t   isdirt   refactor_dirt   refactor_file(   R‰   t   itemst   writet   doctests_onlyt   dir_or_file(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   refactor&  s    c         C€  sé   t  j d } xÕ t  j | ƒ D]Ä \ } } } |  j d | ƒ | j ƒ  | j ƒ  xe | D]] } | j d ƒ rW t  j j | ƒ d | k rW t  j j | | ƒ }	 |  j	 |	 | | ƒ qW qW Wg  | D] }
 |
 j d ƒ s¿ |
 ^ q¿ | (q Wd S(   sÄ   Descends down a directory and refactor every Python file found.

        Python files are assumed to have a .py extension.

        Files and subdirectories starting with '.' are skipped.
        t   pys   Descending into %sRB   i   N(
   R   t   extsept   walkRœ   R    R   R   t   splitextR—   R¶   (   R‰   t   dir_nameR¸   R¹   t   py_extt   dirpatht   dirnamest	   filenamesR   t   fullnamet   dn(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRµ   /  s    

c         C€  s�   y t  | d ƒ } Wn' t k
 r< } |  j d | | ƒ d SXz t j | j ƒ d } Wd | j ƒ  Xt | d d | ƒ� } t	 | j
 ƒ  ƒ | f SWd QXd S(   sG   
        Do our best to decode a Python source file correctly.
        t   rbs   Can't open %s: %si    NR-   t   encoding(   NN(   t   opent   IOErrorR¬   R$   R   t   detect_encodingRT   t   closet   _open_with_encodingRK   t   read(   R‰   R±   t   ft   errRÈ   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   _read_python_sourceC  s    c         C€  s  |  j  | ƒ \ } } | d k r% d S| d 7} | r› |  j d | ƒ |  j | | ƒ } |  j sl | | k rˆ |  j | | | | | ƒ qþ |  j d | ƒ nc |  j | | ƒ } |  j sÅ | rî | j rî |  j t | ƒ d  | d | d | ƒn |  j d | ƒ d S(	   s   Refactors a file.Nu   
s   Refactoring doctests in %ss   No doctest changes in %siÿÿÿÿR¸   RÈ   s   No changes in %s(	   RÑ   R$   Rœ   t   refactor_docstringRj   t   processed_filet   refactor_stringt   was_changedt   unicode(   R‰   R±   R¸   R¹   RJ   RÈ   t   outputt   tree(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR¶   S  s    
c         C€  s·   t  | ƒ } d | k r* t j |  j _ n  zM y |  j j | ƒ } Wn0 t k
 ru } |  j d | | j j	 | ƒ d SXWd |  j |  j _ X| | _
 |  j d | ƒ |  j | | ƒ | S(   sF  Refactor a given input string.

        Args:
            data: a string holding the code to be refactored.
            name: a human-readable name for use in error/log messages.

        Returns:
            An AST corresponding to the refactored input stream; None if
            there were errors during the parse.
        Ri   s   Can't parse %s: %s: %sNs   Refactoring %s(   Re   R   Rs   R   Rt   t   parse_stringR+   R¬   t	   __class__R   t   future_featuresRœ   t   refactor_tree(   R‰   t   dataR   Rb   RØ   RÐ   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRÔ   j  s     			c         C€  sÆ   t  j j ƒ  } | ro |  j d ƒ |  j | d ƒ } |  j sI | | k r_ |  j | d | ƒ qÂ |  j d ƒ nS |  j | d ƒ } |  j s™ | rµ | j rµ |  j t	 | ƒ d | ƒ n |  j d ƒ d  S(   Ns   Refactoring doctests in stdins   <stdin>s   No doctest changes in stdins   No changes in stdin(
   t   syst   stdinRÎ   Rœ   RÒ   Rj   RÓ   RÔ   RÕ   RÖ   (   R‰   R¹   RJ   R×   RØ   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   refactor_stdin…  s    c   
      C€  s›  x- t  |  j |  j ƒ D] } | j | | ƒ q W|  j |  j | j ƒ  ƒ |  j |  j | j ƒ  ƒ |  j j | j	 ƒ  ƒ } xçt
 | j ƒ  ƒ rcxÎ|  j j D]À} | | k rœ | | rœ | | j d t j j d t ƒ | j rþ | | j d t j j ƒ n  x[t | | ƒ D]F} | | | k r9| | j | ƒ n  y t | ƒ Wn t k
 r]qn X| j r|| | j k r|qn  | j | ƒ } | r| j | | ƒ } | d k	 rU| j | ƒ x9 | j ƒ  D]+ } | j säg  | _ n  | j j | ƒ qÉW|  j j | j	 ƒ  ƒ } x? | D]4 }	 |	 | k r6g  | |	 <n  | |	 j | |	 ƒ qWqUqqWqœ qœ Wq} Wx- t  |  j |  j ƒ D] } | j | | ƒ qzW| j  S(   sÏ  Refactors a parse tree (modifying the tree in place).

        For compatible patterns the bottom matcher module is
        used. Otherwise the tree is traversed node-to-node for
        matches.

        Args:
            tree: a pytree.Node instance representing the root of the tree
                  to be refactored.
            name: a human-readable name for this tree.

        Returns:
            True if the tree was modified, False otherwise.
        R‘   t   reverseN(!   R   R}   R~   t
   start_treet   traverse_byR‡   Rˆ   R‚   t   runt   leavest   anyt   valuesRn   R    R   t   Baset   depthRY   t   keep_line_ordert
   get_linenoR2   t   removeR   t
   ValueErrort   fixers_appliedt   matcht	   transformR$   RI   R   R9   t   finish_treeRÕ   (
   R‰   RØ   R   R>   t	   match_sett   nodet   resultst   newt   new_matchest   fxr(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRÜ   •  sJ     		.c         C€  sƒ   | s
 d Sxr | D]j } xa | | j  D]R } | j | ƒ } | r% | j | | ƒ } | d k	 rw | j | ƒ | } qw q% q% Wq Wd S(   s  Traverse an AST, applying a set of fixers to each node.

        This is a helper method for refactor_tree().

        Args:
            fixers: a list of fixer instances.
            traversal: a generator that yields AST nodes.

        Returns:
            None
        N(   R#   Rï   Rð   R$   RI   (   R‰   Rn   t	   traversalRó   R>   Rô   Rõ   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRã   ä  s    c         C€  s½   |  j  j | ƒ | d k rB |  j | ƒ d } | d k rB d Sn  | | k } |  j | | | | ƒ | rŠ |  j d | ƒ |  j sŠ d Sn  | r© |  j | | | | ƒ n |  j d | ƒ d S(   sR   
        Called when a file has been refactored and there may be changes.
        i    Ns   No changes to %ss   Not writing changes to %s(   R   R   R$   RÑ   R³   Rœ   Rj   t
   write_file(   R‰   R°   R±   R¯   R¸   RÈ   R²   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRÓ   û  s    	c         C€  s¸   y t  | d d | ƒ} Wn* t j k
 rE } |  j d | | ƒ d SXzG y | j t | ƒ ƒ Wn) t j k
 r‹ } |  j d | | ƒ n XWd | j ƒ  X|  j d | ƒ t |  _	 d S(   sÑ   Writes a string to a file.

        It first shows a unified diff between the old text and the new text, and
        then rewrites the file; the latter is only done if the write option is
        set.
        t   wRÈ   s   Can't create %s: %sNs   Can't write %s: %ss   Wrote changes to %s(
   RÍ   R   t   errorR¬   R¸   RM   RÌ   Rœ   RY   Rz   (   R‰   R°   R±   R¯   RÈ   RÏ   RÐ   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRù     s     s   >>> s   ... c   
      C€  s‡  g  } d } d } d } d } x+| j t ƒ D]} | d 7} | j ƒ  j |  j ƒ r² | d k	 r„ | j |  j | | | | ƒ ƒ n  | } | g } | j |  j ƒ }	 | |	  } q. | d k	 r| j | |  j	 ƒ sñ | | |  j	 j
 ƒ  d k r| j | ƒ q. | d k	 r/| j |  j | | | | ƒ ƒ n  d } d } | j | ƒ q. W| d k	 rz| j |  j | | | | ƒ ƒ n  d j | ƒ S(   sË  Refactors a docstring, looking for doctests.

        This returns a modified version of the input string.  It looks
        for doctests, which start with a ">>>" prompt, and may be
        continued with "..." prompts, as long as the "..." is indented
        the same as the ">>>".

        (Unfortunately we can't use the doctest module's parser,
        since, like most parsers, it is not geared towards preserving
        the original source.)
        i    i   u   
u    N(   R$   t
   splitlinesRY   t   lstripR   t   PS1R9   t   refactor_doctestt   findt   PS2t   rstripR   R—   (
   R‰   RJ   R±   t   resultt   blockt   block_linenot   indentt   linenot   linet   i(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRÒ   (  s:    
	c   
      C€  ss  y |  j  | | | ƒ } Wnu t k
 r� } |  j j t j ƒ rm x* | D] } |  j d | j d ƒ ƒ qG Wn  |  j d | | | j	 j
 | ƒ | SX|  j | | ƒ rot | ƒ j t ƒ } | | d  | | d }	 } |	 d g | d k sø t |	 ƒ ‚ | d j d ƒ s| d c d 7<n  | |  j | j d ƒ g } | ro| g  | D] } | |  j | ^ qK7} qon  | S(   sÞ   Refactors one doctest.

        A doctest is given as a block of lines, the first of which starts
        with ">>>" (possibly indented), while the remaining lines start
        with "..." (identically indented).

        s
   Source: %su   
s+   Can't parse docstring in %s line %s: %s: %si   iÿÿÿÿi    (   t   parse_blockR+   Rm   t   isEnabledForRw   t   DEBUGRœ   R  R¬   RÚ   R   RÜ   RÖ   Rü   RY   t   AssertionErrorR   Rþ   t   popR  (
   R‰   R  R  R  R±   RØ   RÐ   R  Rõ   t   clipped(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRÿ   S  s&     	#.c         C€  s  |  j  r d } n d } |  j s4 |  j d | ƒ n1 |  j d | ƒ x |  j D] } |  j | ƒ qN W|  j rŸ |  j d ƒ x! |  j D] } |  j | ƒ q… Wn  |  j rt |  j ƒ d k rÍ |  j d ƒ n |  j d t |  j ƒ ƒ x0 |  j D]" \ } } } |  j | | | Ž qð Wn  d  S(	   Nt   weres
   need to bes   No files %s modified.s   Files that %s modified:s$   Warnings/messages while refactoring:i   s   There was 1 error:s   There were %d errors:(   Rz   R   R›   Ry   Rv   R”   (   R‰   R  t   filet   messageR©   Rª   R«   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt	   summarizep  s$    					c         C€  s1   |  j  j |  j | | | ƒ ƒ } t ƒ  | _ | S(   s³   Parses a block into a tree.

        This is necessary to get correct line number / offset information
        in the parser diagnostics and embedded into the parse tree.
        (   R   t   parse_tokenst	   wrap_toksRU   RÛ   (   R‰   R  R  R  RØ   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR
  ‡  s    !c         c€  sŠ   t  j |  j | | ƒ j ƒ } xe | D]] \ } } \ } } \ }	 }
 } | | d 7} |	 | d 7}	 | | | | f |	 |
 f | f Vq% Wd S(   s;   Wraps a tokenize stream to systematically modify start/end.i   N(   R   RR   t	   gen_linesRN   (   R‰   R  R  R  R8   R#   Rd   t   line0t   col0t   line1t   col1t	   line_text(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR  ‘  s
    (c         c€  s¢   | |  j  } | |  j } | } xi | D]a } | j | ƒ rN | t | ƒ Vn4 | | j ƒ  d k rl d Vn t d | | f ƒ ‚ | } q' Wx t r� d Vq� Wd S(   s–   Generates lines as expected by tokenize from a list of lines.

        This strips the first len(indent + self.PS1) characters off each line.
        u   
s   line=%r, prefix=%rR�   N(   Rþ   R  R   R”   R  R  RY   (   R‰   R  R  t   prefix1t   prefix2t   prefixR  (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR  Ÿ  s    
	N(   R   R   RC   Rp   R–   R“   R$   R‹   R|   R¬   R›   Rœ   R³   R»   Rµ   RÑ   R¶   RÔ   Rà   RÜ   Rã   RÓ   Rù   Rþ   R  RÒ   Rÿ   R  R
  R  R  (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyRh   ®   s:   

4	(								O		+			
	t   MultiprocessingUnsupportedc           B€  s   e  Z RS(    (   R   R   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR  ³  s   t   MultiprocessRefactoringToolc           B€  s5   e  Z d  „  Z e e d d „ Z d „  Z d „  Z RS(   c         O€  s/   t  t |  ƒ j | | Ž  d  |  _ d  |  _ d  S(   N(   t   superR   R‹   R$   t   queuet   output_lock(   R‰   Rª   t   kwargs(    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR‹   ¹  s    	i   c   	      C€  sf  | d k r( t  t |  ƒ j | | | ƒ Sy d d  l } Wn t k
 rQ t ‚ n X|  j d  k	 rp t d ƒ ‚ n  | j	 ƒ  |  _ | j
 ƒ  |  _ g  t | ƒ D] } | j d |  j ƒ ^ q› } z; x | D] } | j ƒ  qÆ Wt  t |  ƒ j | | | ƒ Wd  |  j j ƒ  x$ t | ƒ D] } |  j j d  ƒ qWx' | D] } | j ƒ  r5| j ƒ  q5q5Wd  |  _ Xd  S(   Ni   iÿÿÿÿs    already doing multiple processest   target(   R!  R   R»   t   multiprocessingt   ImportErrorR  R"  R$   t   RuntimeErrort   JoinableQueuet   LockR#  t   xranget   Processt   _childt   startR—   t   putt   is_alive(	   R‰   R·   R¸   R¹   t   num_processesR&  R	  t	   processesR.   (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR»   ¾  s2    
+c         C€  so   |  j  j ƒ  } xY | d  k	 rj | \ } } z t t |  ƒ j | | Ž  Wd  |  j  j ƒ  X|  j  j ƒ  } q Wd  S(   N(   R"  Ru   R$   R!  R   R¶   t	   task_done(   R‰   t   taskRª   R$  (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR-  Û  s    c         O€  sE   |  j  d  k	 r( |  j  j | | f ƒ n t t |  ƒ j | | Ž  Sd  S(   N(   R"  R$   R/  R!  R   R¶   (   R‰   Rª   R$  (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR¶   æ  s    (   R   R   R‹   RC   R»   R-  R¶   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyR   ·  s
   		(-   Rg   t
   __future__R    t
   __author__R   RÞ   Rw   Rž   R0   RS   t	   itertoolsR   t   pgen2R   R   R   t
   fixer_utilR   R�   R   R   R   t   buR	   R€   RY   R   R+   R   R(   RA   RF   RH   t   version_infot   codecsRÉ   RÍ   RK   RM   Re   Rf   t   objectRh   R  R   (    (    (    s<   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/lib2to3/refactor.pyt   <module>	   sF   							(ÿ ÿ 