Ñò
4×ÛQc           @   s^   d  Z  d d k Z d d k Z d d k Z d d k Z e i d ƒ Z d „  Z d d „ Z
 d S(   s4   Utility to use the Closure Compiler CLI from Python.iÿÿÿÿNs   "([0-9][.0-9]*)c          C   sV   t  i d d g d t  i ƒ}  |  i ƒ  \ } } | i ƒ  d } t i | ƒ i d ƒ S(   s=   Returns the string for the current version of Java installed.t   javas   -versiont   stderri    i   (   t
   subprocesst   Popent   PIPEt   communicatet
   splitlinest   _VERSION_REGEXt   searcht   group(   t   proct   unused_stdoutdatat
   stderrdatat   version_line(    (    s&   ../tools\closure_library_jscompiler.pyt   _GetJavaVersion   s    c         C   sÛ   t  i i t ƒ  ƒ t  i i d ƒ j p t i d ƒ d Sd d |  g } x | D] } | d | g 7} qP W| o | | 7} n t i d d i | ƒ ƒ t i	 | d	 t i
 ƒ} | i ƒ  \ } } | i d
 j o d S| S(   sD  Prepares command-line call to Closure Compiler.

  Args:
    compiler_jar_path: Path to the Closure compiler .jar file.
    source_paths: Source paths to build, in order.
    flags: A list of additional flags to pass on to Closure Compiler.

  Returns:
    The compiled source, as a string, or None if compilation failed.
  s   1.6sV   Closure Compiler requires Java 1.6 or higher. Please visit http://www.java.com/getjavaNR    s   -jars   --jss(   Compiling with the following command: %st    t   stdouti    (   t	   distutilst   versiont   LooseVersionR   t   loggingt   errort   infot   joinR   R   R   R   t
   returncode(   t   compiler_jar_patht   source_pathst   flagst   argst   pathR
   t
   stdoutdatat   unused_stderrdata(    (    s&   ../tools\closure_library_jscompiler.pyt   Compile%   s      (   t   __doc__t   distutils.versionR   R   t   reR   t   compileR   R   t   NoneR    (    (    (    s&   ../tools\closure_library_jscompiler.pyt   <module>   s   	