ó
ÓnäZc           @   sg   d  Z  d d l Z d d l j Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(	   s$   Visual Studio project reader/writer.iÿÿÿÿNt   Toolc           B   s#   e  Z d  Z d d „ Z d „  Z RS(   s   Visual Studio tool.c         C   s    | p	 i  |  _  | |  j  d <d S(   so   Initializes the tool.

    Args:
      name: Tool name.
      attrs: Dict of tool attributes; may be None.
    t   NameN(   t   _attrs(   t   selft   namet   attrs(    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt   __init__   s    c         C   s   d |  j  g S(   s]   Creates an element for the tool.

    Returns:
      A new xml.dom.Element for the tool.
    R    (   R   (   R   (    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt   _GetSpecification   s    N(   t   __name__t
   __module__t   __doc__t   NoneR   R   (    (    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyR       s   
t   Filterc           B   s   e  Z d  Z d d „ Z RS(   s1   Visual Studio filter - that is, a virtual folder.c         C   s"   | |  _  t | p g  ƒ |  _ d S(   sŒ   Initializes the folder.

    Args:
      name: Filter (folder) name.
      contents: List of filenames and/or Filter objects contained.
    N(   R   t   listt   contents(   R   R   R   (    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyR   %   s    	N(   R   R	   R
   R   R   (    (    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyR   "   s   t   Writerc           B   sh   e  Z d  Z d	 d	 d „ Z d „  Z d „  Z d	 d	 d „ Z d „  Z d „  Z	 d	 d	 d „ Z
 d „  Z RS(
   s!   Visual Studio XML project writer.c         C   s¤   | |  _  | |  _ | |  _ | |  _ | s6 d g } n  d g |  _ x+ | D]# } |  j j d i | d 6g ƒ qI Wd g |  _ d g |  _ d g |  _ t	 ƒ  |  _
 d S(	   s  Initializes the project.

    Args:
      project_path: Path to the project file.
      version: Format version to emit.
      name: Name of the project.
      guid: GUID to use for project, if not None.
      platforms: Array of string, the supported platforms.  If null, ['Win32']
    t   Win32t	   Platformst   PlatformR   t	   ToolFilest   Configurationst   FilesN(   t   project_patht   versionR   t   guidt   platform_sectiont   appendt   tool_files_sectiont   configurations_sectiont   files_sectiont   dictt
   files_dict(   R   R   R   R   R   t	   platformst   platform(    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyR   6   s    
				!c         C   s!   |  j  j d i | d 6g ƒ d S(   se   Adds a tool file to the project.

    Args:
      path: Relative path from project to tool file.
    t   ToolFilet   RelativePathN(   R   R   (   R   t   path(    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt   AddToolFileT   s    c         C   sœ   | s i  } n  | s g  } n  | j  ƒ  } | | d <| | g } | r˜ xO | D]D } t | t ƒ rx | j | j ƒ  ƒ qM | j t | ƒ j ƒ  ƒ qM Wn  | S(   s   Returns the specification for a configuration.

    Args:
      config_type: Type of configuration node.
      config_name: Configuration name.
      attrs: Dict of configuration attributes; may be None.
      tools: List of tools (strings or Tool objects); may be None.
    Returns:
    R   (   t   copyt
   isinstanceR    R   R   (   R   t   config_typet   config_nameR   t   toolst
   node_attrst   specificationt   t(    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt   _GetSpecForConfiguration\   s    		
 c         C   s,   |  j  d | | | ƒ } |  j j | ƒ d S(   sÓ   Adds a configuration to the project.

    Args:
      name: Configuration name.
      attrs: Dict of configuration attributes; may be None.
      tools: List of tools (strings or Tool objects); may be None.
    t   ConfigurationN(   R.   R   R   (   R   R   R   R*   t   spec(    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt	   AddConfig{   s    c         C   s}   xv | D]n } t  | t ƒ rH d i | j d 6g } |  j | | j ƒ n  d i | d 6g } | |  j | <| j | ƒ q Wd S(   sð   Adds files and/or filters to the parent node.

    Args:
      parent: Destination node
      files: A list of Filter objects and/or relative paths to files.

    Will call itself recursively, if the files list contains Filter objects.
    R   R   t   FileR#   N(   R'   R   R   t   _AddFilesToNodeR   R   R   (   R   t   parentt   filest   ft   node(    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyR3   †   s    	c         C   s   |  j  |  j | ƒ d S(   sK  Adds files to the project.

    Args:
      files: A list of Filter objects and/or relative paths to files.

    This makes a copy of the file/filter tree at the time of this call.  If you
    later add files to a Filter object which was passed into a previous call
    to AddFiles(), it will not be reflected in this project.
    N(   R3   R   (   R   R5   (    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt   AddFiles˜   s    
c         C   sT   |  j  j | ƒ } | s+ t d | ƒ ‚ n  |  j d | | | ƒ } | j | ƒ d S(   s\  Adds a configuration to a file.

    Args:
      path: Relative path to the file.
      config: Name of configuration to add.
      attrs: Dict of configuration attributes; may be None.
      tools: List of tools (strings or Tool objects); may be None.

    Raises:
      ValueError: Relative path does not match any file added via AddFiles().
    s(   AddFileConfig: file "%s" not in project.t   FileConfigurationN(   R   t   gett
   ValueErrorR.   R   (   R   R$   t   configR   R*   R4   R0   (    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt   AddFileConfig¦   s    	c         C   s‰   d i d d 6|  j  j ƒ  d 6|  j d 6|  j d 6|  j d 6d d	 6|  j |  j |  j d
 g |  j d g g } t j	 | |  j
 d d ƒd S(   s   Writes the project file.t   VisualStudioProjects
   Visual C++t   ProjectTypet   VersionR   t   ProjectGUIDt   RootNamespacet	   Win32Projt   Keywordt
   Referencest   Globalst   encodings   Windows-1252N(   R   t   ProjectVersionR   R   R   R   R   R   t   easy_xmlt   WriteXmlIfChangedR   (   R   t   content(    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt   WriteIfChanged¼   s    



N(   R   R	   R
   R   R   R%   R.   R1   R3   R8   R=   RL   (    (    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyR   3   s   				(	   R
   t
   gyp.commont   gypt   gyp.easy_xmlRI   t   objectR    R   R   (    (    (    s3   /usr/lib/python2.7/dist-packages/gyp/MSVSProject.pyt   <module>   s
   