Ñò
WÉëPc           @   sm   d  Z  d Z d d k Z d Z e i e d ƒ Z e i e d ƒ Z d Z d e f d	 „  ƒ  YZ	 d
 „  Z
 d S(   s‡   Scans a source JS file for its provided and required namespaces.

Simple class to scan a JavaScript file and express its dependencies.
s   nnaze@google.comiÿÿÿÿNs"   ^\s*goog\.%s\(\s*['"](.+)['"]\s*\)t   providet   requiresC   var goog = goog || {}; // Identifies this file as the Closure base.t   Sourcec           B   sd   e  Z d  Z e i d e i e i Be i Bƒ Z d „  Z	 d „  Z
 d „  Z e d „  ƒ Z d „  Z RS(   sC   Scans a JavaScript source for its provided and required namespaces.s°   
      ^\s*   # Start of a new line and whitespace
      /\*    # Opening "/*"
      .*?    # Non greedy match of any characters (including newlines)
      \*/    # Closing "*/c         C   s/   t  ƒ  |  _ t  ƒ  |  _ | |  _ |  i ƒ  d S(   sN   Initialize a source.

    Args:
      source: str, The JavaScript source.
    N(   t   sett   providest   requirest   _sourcet   _ScanSource(   t   selft   source(    (    s=   /home/yoya/public_html/js/mid.js/closure-primitives/source.pyt   __init__2   s    	c         C   s   d |  i  S(   Ns	   Source %s(   t   _path(   R   (    (    s=   /home/yoya/public_html/js/mid.js/closure-primitives/source.pyt   __str__?   s    c         C   s   |  i  S(   s   Get the source as a string.(   R   (   R   (    (    s=   /home/yoya/public_html/js/mid.js/closure-primitives/source.pyt	   GetSourceB   s    c         C   s   |  i  i d | ƒ S(   Nt    (   t   _COMMENT_REGEXt   sub(   t   clsR	   (    (    s=   /home/yoya/public_html/js/mid.js/closure-primitives/source.pyt   _StripCommentsF   s    c         C   sþ   |  i  |  i ƒ  ƒ } | i ƒ  } xt | D]l } t i | ƒ } | o |  i i | i d ƒ ƒ n t i | ƒ } | o |  i	 i | i d ƒ ƒ q( q( Wx_ | D]W } | t
 j oD t |  i ƒ p t |  i	 ƒ o t d ƒ ‚ n |  i i d ƒ qŸ qŸ Wd S(   s5   Fill in provides and requires by scanning the source.i   s4   Base files should not provide or require namespaces.t   googN(   R   R   t
   splitlinest   _PROVIDE_REGEXt   matchR   t   addt   groupt   _REQUIRES_REGEXR   t   _GOOG_BASE_LINEt   lent	   Exception(   R   R	   t   source_linest   lineR   (    (    s=   /home/yoya/public_html/js/mid.js/closure-primitives/source.pyR   J   s"     !  (   t   __name__t
   __module__t   __doc__t   ret   compilet	   MULTILINEt   DOTALLt   VERBOSER   R
   R   R   t   classmethodR   R   (    (    (    s=   /home/yoya/public_html/js/mid.js/closure-primitives/source.pyR   #   s   			c         C   s,   t  |  ƒ } z | i ƒ  SWd | i ƒ  Xd S(   sº   Get a file's contents as a string.

  Args:
    path: str, Path to file.

  Returns:
    str, Contents of file.

  Raises:
    IOError: An error occurred opening or reading the file.

  N(   t   opent   readt   close(   t   patht   fileobj(    (    s=   /home/yoya/public_html/js/mid.js/closure-primitives/source.pyt   GetFileContentsa   s    (   R!   t
   __author__R"   t   _BASE_REGEX_STRINGR#   R   R   R   t   objectR   R-   (    (    (    s=   /home/yoya/public_html/js/mid.js/closure-primitives/source.pyt   <module>   s   >