ó
†Å•Zc           @   s   d  Z  d d l Z d d l m Z m Z e j d ƒ d „  ƒ Z e j d ƒ d „  ƒ Z e j d e j	 ƒ  e j
 ƒ  f ƒ Z e j d ƒ Z d S(	   sR   A module to ease code analysis

This module is here to help source code analysis.
iÿÿÿÿN(   t   codeanalyzet   utilsi   c   	      C   sm  t  j |  ƒ } xd t |  ƒ D]V \ } } |  | d k rI d | | } n d d | | d } | j | | | ƒ q W| j ƒ  p… |  }  t  j |  ƒ } d } x“ t j |  ƒ D]‚ } | j ƒ  } | j ƒ  } | d k rä | d 7} n  | d k rý | d 8} n  | d	 k r­ | d k r­ | j | | d d ƒ q­ q­ W| j ƒ  pB|  }  |  j	 d
 d ƒ j	 d d ƒ j	 d d	 ƒ S(   s7  Simplify `source` for analysis

    It replaces:

    * comments with spaces
    * strs with a new str filled with spaces
    * implicit and explicit continuations with spaces
    * tabs and semicolons with spaces

    The resulting code is a lot easier to analyze if we are interested
    only in offsets.
    t   #t    s   "%s"i   i    s   ({[i   s   )}]s   
s   \
s     s   	t   ;(
   R    t   ChangeCollectort   ignored_regionst
   add_changet   get_changedt   _parenst   finditert   startt   groupt   replace(	   t   sourcet	   collectorR   t   endt   replacementt   parenst   matcht   it   c(    (    s1   lib/python2.7/site-packages/rope/base/simplify.pyt	   real_code
   s(    c         C   s2   g  t  j |  ƒ D] } | j ƒ  | j ƒ  f ^ q S(   s=   Return ignored regions like strings and comments in `source` (   t   _strR
   R   R   (   R   R   (    (    s1   lib/python2.7/site-packages/rope/base/simplify.pyR   /   s    s   %s|%ss   [\({\[\]}\)\n](   t   __doc__t   ret	   rope.baseR    R   t   cachedR   R   t   compilet   get_comment_patternt   get_string_patternR   R	   (    (    (    s1   lib/python2.7/site-packages/rope/base/simplify.pyt   <module>   s   %