ó
ô"“Xc           @   sˆ   d  Z  d Z d d l Z d d l Z d Z e j e d ƒ Z e j e d ƒ Z d Z e j e ƒ 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   modulet   providesa   ^\s*(?:(?:var|let|const)\s+[a-zA-Z_$][a-zA-Z0-9$_]*\s*=\s*)?goog\.require\(\s*[\'"](.+)[\'"]\s*\)t   Sourcec           B   sj   e  Z d  Z e j d e j e j Be j Bƒ Z d „  Z	 d „  Z
 e 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   s8   t  ƒ  |  _ t  ƒ  |  _ t |  _ | |  _ |  j ƒ  d S(   sN   Initialize a source.

    Args:
      source: str, The JavaScript source.
    N(   t   sett   providest   requirest   Falset   is_goog_modulet   _sourcet   _ScanSource(   t   selft   source(    (    s¹   /Users/ahocevar/projects/openlayers.github.io/.grunt/openlayers-website/repo/node_modules/closure-util/.deps/library/411062e6cc01c477c9504cf3b3e8ac4a58b92e2a/closure/bin/build/source.pyt   __init__2   s
    		c         C   s   |  j  S(   s   Get the source as a string.(   R   (   R
   (    (    s¹   /Users/ahocevar/projects/openlayers.github.io/.grunt/openlayers-website/repo/node_modules/closure-util/.deps/library/411062e6cc01c477c9504cf3b3e8ac4a58b92e2a/closure/bin/build/source.pyt	   GetSource@   s    c         C   s   |  j  j d | ƒ S(   Nt    (   t   _COMMENT_REGEXt   sub(   t   clsR   (    (    s¹   /Users/ahocevar/projects/openlayers.github.io/.grunt/openlayers-website/repo/node_modules/closure-util/.deps/library/411062e6cc01c477c9504cf3b3e8ac4a58b92e2a/closure/bin/build/source.pyt   _StripCommentsD   s    c         C   s1   x* |  j  j | ƒ D] } d | k r t Sq Wt S(   s9   Determines whether the @provideGoog flag is in a comment.s   @provideGoog(   R   t   findallt   TrueR   (   R   R   t   comment_content(    (    s¹   /Users/ahocevar/projects/openlayers.github.io/.grunt/openlayers-website/repo/node_modules/closure-util/.deps/library/411062e6cc01c477c9504cf3b3e8ac4a58b92e2a/closure/bin/build/source.pyt   _HasProvideGoogFlagH   s    c         C   s'  |  j  |  j ƒ  ƒ } | j ƒ  } xª | D]¢ } t j | ƒ } | r_ |  j j | j d ƒ ƒ n  t j | ƒ } | r™ |  j j | j d ƒ ƒ t	 |  _
 n  t j | ƒ } | r( |  j j | j d ƒ ƒ q( q( W|  j |  j ƒ  ƒ r#t |  j ƒ st |  j ƒ rt d ƒ ‚ n  |  j j d ƒ n  d S(   s5   Fill in provides and requires by scanning the source.i   s3   Base file should not provide or require namespaces.t   googN(   R   R   t
   splitlinest   _PROVIDE_REGEXt   matchR   t   addt   groupt   _MODULE_REGEXR   R   t   _REQUIRES_REGEXR   R   t   lent	   Exception(   R
   t   stripped_sourcet   source_linest   lineR   (    (    s¹   /Users/ahocevar/projects/openlayers.github.io/.grunt/openlayers-website/repo/node_modules/closure-util/.deps/library/411062e6cc01c477c9504cf3b3e8ac4a58b92e2a/closure/bin/build/source.pyR	   Q   s$     (   t   __name__t
   __module__t   __doc__t   ret   compilet	   MULTILINEt   DOTALLt   VERBOSER   R   R   t   classmethodR   R   R	   (    (    (    s¹   /Users/ahocevar/projects/openlayers.github.io/.grunt/openlayers-website/repo/node_modules/closure-util/.deps/library/411062e6cc01c477c9504cf3b3e8ac4a58b92e2a/closure/bin/build/source.pyR   #   s   			c         C   sz   d } zS y# t j |  d d ƒ} | j ƒ  SWn) t k
 rW } t d |  | f ƒ ‚ n XWd | d k	 ru | j ƒ  n  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.

  t   encodings	   utf-8-sigs5   An error occurred opening or reading the file: %s. %sN(   t   Nonet   codecst   opent   readt   IOErrort   close(   t   patht   fileobjt   error(    (    s¹   /Users/ahocevar/projects/openlayers.github.io/.grunt/openlayers-website/repo/node_modules/closure-util/.deps/library/411062e6cc01c477c9504cf3b3e8ac4a58b92e2a/closure/bin/build/source.pyt   GetFileContentsn   s     (   R&   t
   __author__R/   R'   t   _BASE_REGEX_STRINGR(   R   R   t   _REQUIRE_REGEX_STRINGR   t   objectR   R7   (    (    (    s¹   /Users/ahocevar/projects/openlayers.github.io/.grunt/openlayers-website/repo/node_modules/closure-util/.deps/library/411062e6cc01c477c9504cf3b3e8ac4a58b92e2a/closure/bin/build/source.pyt   <module>   s   K