σ
ΌS]c           @@  sh   d  Z  d d l m Z d d l Z d d l m Z m Z m Z d	 Z e d Z	 d e f d     YZ
 d S(
   s+   Project lock file loading and manipulation.i    (   t   absolute_importN(   t   YamlFilet   _CommentedMapt   _block_style_all_nodess   anaconda-project-lock.ymls   anaconda-project-lock.yamlt   ProjectLockFilec           B@  sP   e  Z d  Z d Z e d    Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   sZ   Represents the ``anaconda-project-lock.yml`` file which describes locked package versions.sτ  
# This is an Anaconda project lock file.
# The lock file locks down exact versions of all your dependencies.
#
# In most cases, this file is automatically maintained by the `anaconda-project` command or GUI tools.
# It's best to keep this file in revision control (such as git or svn).
# The file is in YAML format, please see http://www.yaml.org/start.html for more.
#

#
# Set to false to ignore locked versions.
#
locking_enabled: false

#
# A key goes in here for each env spec.
#
env_specs: {}
c         C@  s[   x? t  D]7 } t j j | |  } t j j |  r t |  Sq Wt t j j | t   S(   sΥ  Load the project lock file from the given directory, even if it doesn't exist.

        If the directory has no project file, the loaded
        ``ProjectLockFile`` will be empty. It won't actually be
        created on disk unless you call ``save()``.

        If the file has syntax problems, this sets the
        ``corrupted`` and ``corrupted_error_message`` properties,
        and attempts to modify the file will raise an
        exception. If the project file has semantic problems, they
        are not detected by this class but are reported by the
        ``Project`` class.

        Args:
            directory (str): path to the project directory

        Returns:
            a new ``ProjectLockFile``

        (   t    possible_project_lock_file_namest   ost   patht   joint   isfileR   t   DEFAULT_PROJECT_LOCK_FILENAME(   t   clst	   directoryt   nameR   (    (    sA   lib/python2.7/site-packages/anaconda_project/project_lock_file.pyt   load_for_directory,   s
    c         C@  s   t  t |   j |  d S(   s&  Construct a ``ProjectLockFile`` with the given filename.

        It's easier to use ``ProjectLockFile.load_for_directory()`` in most cases.

        If the file has syntax problems, this sets the
        ``corrupted`` and ``corrupted_error_message`` properties,
        and attempts to modify the file will raise an
        exception. If the project file has semantic problems, they
        are not detected by this class but are reported by the
        ``Project`` class.

        Args:
            filename (str): path to the project file
        N(   t   superR   t   __init__(   t   selft   filename(    (    sA   lib/python2.7/site-packages/anaconda_project/project_lock_file.pyR   H   s    c         C@  s   t  S(   N(   t   False(   R   (    (    sA   lib/python2.7/site-packages/anaconda_project/project_lock_file.pyt   _save_default_contentY   s    c         C@  s   |  j  d | d g |  d S(   s   Library-internal method.t	   env_specst   env_spec_hashN(   t	   set_value(   R   t   env_spec_nameR   (    (    sA   lib/python2.7/site-packages/anaconda_project/project_lock_file.pyt   _set_lock_set_hash]   s    c   	      C@  sT  | d k	 s t  | d k	 s$ t  | d k	 s6 t  | | k sH t  |  j d g t  } | s.|  j d g t  |  j d g d  } | d k rΐ t   } t |  |  j d g |  n  xk | D]` } | | k rί qΗ n  | j | d  } | d k rt   } t |  | | | <n  t | d <qΗ Wn  | j	   } |  j d | g |  d S(   s   Library-internal method.t   locking_enabledR   t   lockedN(
   t   Nonet   AssertionErrort	   get_valuet   TrueR   R   R   t   getR   t   to_json(	   R   R   t   lock_sett	   all_namest   for_allt   new_env_specsR   t
   single_envt   as_json(    (    sA   lib/python2.7/site-packages/anaconda_project/project_lock_file.pyt   _set_lock_seta   s.    	
	
c         C@  s{   | d k r2 |  j d g t  |  j d g  nE |  j d | d g t  |  j d | d g  |  j d | d g  d S(   s   Library-internal method.R   R   R   t   packagest	   platformsN(   R   R   R   t   unset_value(   R   R   (    (    sA   lib/python2.7/site-packages/anaconda_project/project_lock_file.pyt   _disable_locking   s    (   t   __name__t
   __module__t   __doc__t   templatet   classmethodR   R   R   R   R(   R,   (    (    (    sA   lib/python2.7/site-packages/anaconda_project/project_lock_file.pyR      s   				#(   s   anaconda-project-lock.ymls   anaconda-project-lock.yaml(   R/   t
   __future__R    R   t   anaconda_project.yaml_fileR   R   R   R   R
   R   (    (    (    sA   lib/python2.7/site-packages/anaconda_project/project_lock_file.pyt   <module>   s   
