ó
¼S]c           @@ sx   d  Z  d d l m Z m Z d d l Z d d l m Z d d l m Z d d l	 m
 Z
 d Z d e f d „  ƒ  YZ d S(   s   File download requirements.i    (   t   absolute_importt   print_functionN(   t   EnvVarRequirement(   t   urlparse(   t	   is_stringt   md5t   sha1t   sha224t   sha256t   sha384t   sha512t   DownloadRequirementc           B@ se   e  Z d  Z e d „  ƒ Z d d e d d „ Z e d „  ƒ Z	 e d „  ƒ Z
 d „  Z d d „ Z RS(   s<   A requirement for ``env_var`` to point to a downloaded file.c         C@ s!  d } d } d } d } d } d }	 t | ƒ r9 | } nwt | t ƒ r°| j d d ƒ } | d k r€ | j d j | ƒ ƒ d S| j d d ƒ }	 |	 d k	 rÅ t |	 ƒ rÅ | j d j | ƒ ƒ d Sxˆ t D]€ }
 |
 | k rä qÌ n  | d k	 r| j d j | | |
 ƒ ƒ d S| |
 } t | ƒ r/|
 } qÌ | j d j | | ƒ ƒ d SqÌ W| j d d ƒ } | j d d ƒ } | d k	 r°t | t ƒ r°| j d	 j | | ƒ ƒ d Sn  | d k sÉt | ƒ rç| j d
 d j | ƒ ƒ d S| d k r| j d j | ƒ ƒ d St	 j
 j t j | ƒ j
 ƒ } | j ƒ  j d ƒ } | d k r•| d k rÆ| } | r’| d k ryt } n  | r| d  } qq’qÆn1 | rÆ| d k rÆ| j ƒ  j d ƒ rÆt } n  | d k rÛ| } n  | d k rðt } n  t d | d | d | d | d | d | d |	 ƒ S(   s*   Parse an item from the downloads: section.t   urls/   Download item {} doesn't contain a 'url' field.t   descriptions8   'description' field for download item {} is not a strings.   Multiple checksums for download {}: {} and {}.s0   Checksum value for {} should be a string not {}.t   filenamet   unzipsB   Value of 'unzip' for download item {} should be a boolean, not {}.sD   Download name {} should be followed by a URL string or a dictionary s   describing the download.t    s*   Download item {} has an empty 'url' field.s   .zipiüÿÿÿt   env_vart   hash_algorithmt
   hash_valueN(   t   NoneR   t
   isinstancet   dictt   gett   appendt   formatt   _hash_algorithmst   boolt   ost   patht   basenameR   t   urlsplitt   lowert   endswitht   Truet   False(   t   clst   varnamet   itemt   problemsR   R   R   R   R   R   t   methodt   url_patht   url_path_is_zip(    (    s[   lib/python2.7/site-packages/anaconda_project/requirements_registry/requirements/download.pyt   _parse   s„    	
			(			c	   
      C@ sì   d }	 | d k	 r$ t d | ƒ }	 n  t t |  ƒ j d | d | d |	 ƒ | d k	 s[ t ‚ | d k	 sm t ‚ t | ƒ d k s… t ‚ t | ƒ d k s t ‚ | |  _ | |  _ | d k sÍ | t	 k sÍ t ‚ | |  _
 | |  _ | |  _ d S(   s.   Extend init to accept url and hash parameters.R   t   registryR   t   optionsi    N(   R   R   t   superR   t   __init__t   AssertionErrort   lenR   R   R   R   R   R   (
   t   selfR,   R   R   R   R   R   R   R   R-   (    (    s[   lib/python2.7/site-packages/anaconda_project/requirements_registry/requirements/download.pyR/   t   s    
%				c         C@ s   |  j  d j |  j ƒ ƒ S(   s.   Override superclass to supply our description.s,   A downloaded file which is referenced by {}.(   t   _descriptionR   R   (   R2   (    (    s[   lib/python2.7/site-packages/anaconda_project/requirements_registry/requirements/download.pyR      s    c         C@ s"   t  d |  j d |  j d g ƒ S(   s-   Override superclass with our ignore patterns.t   /s   .part(   t   setR   (   R2   (    (    s[   lib/python2.7/site-packages/anaconda_project/requirements_registry/requirements/download.pyt   ignore_patterns’   s    c         C@ sI   |  j  | k r |  j ƒ  S| |  j  } t j j | ƒ sE d j | ƒ Sd  S(   Ns   File not found: {}(   R   t   _unset_messageR   R   t   existsR   (   R2   t   environR   (    (    s[   lib/python2.7/site-packages/anaconda_project/requirements_registry/requirements/download.pyt   _why_not_provided—   s
    
c   	      C@ ss   |  j  | ƒ } | d k } | r< d j |  j | ƒ ƒ } n | } |  j | | | d | d | d | d d d | ƒS(	   s&   Override superclass to get our status.s   File downloaded to {}t	   overridest   has_been_providedt   status_descriptiont   provider_class_namet   DownloadProvidert   latest_provide_resultN(   R:   R   R   t   _get_value_of_env_vart   _create_status(	   R2   R9   t   local_state_filet   default_env_spec_nameR;   R@   t   why_not_providedR<   R=   (    (    s[   lib/python2.7/site-packages/anaconda_project/requirements_registry/requirements/download.pyt   check_statusž   s    N(   t   __name__t
   __module__t   __doc__t   classmethodR+   R   R#   R/   t   propertyR   R6   R:   RF   (    (    (    s[   lib/python2.7/site-packages/anaconda_project/requirements_registry/requirements/download.pyR      s   `	(   R   R   R   R   R	   R
   (   RI   t
   __future__R    R   R   t2   anaconda_project.requirements_registry.requirementR   t3   anaconda_project.requirements_registry.network_utilR   t$   anaconda_project.internal.py2_compatR   R   R   (    (    (    s[   lib/python2.7/site-packages/anaconda_project/requirements_registry/requirements/download.pyt   <module>   s   