ó
i4Vdc           @  s¼   d  d l  m Z d  d l Z d  d l m Z d  d l m Z d  d l m Z d  d l	 m
 Z
 d  d l m Z m Z d  d l m Z d  d	 l m Z d  d
 l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   unicode_literalsN(   t   OrderedDict(   t   get_finders(   t   staticfiles_storage(   t   FileSystemStorage(   t   BaseCommandt   CommandError(   t   no_style(   t
   smart_text(   t   inputt   Commandc           B  s€   e  Z d  Z d Z e Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z RS(   uw   
    Command that allows to copy or symlink static files from different
    locations to the settings.STATIC_ROOT.
    u*   Collect static files in a single location.c         O  s   t  t |  ƒ j | | Ž  g  |  _ g  |  _ g  |  _ g  |  _ t |  _ t	 ƒ  |  _
 y |  j j d ƒ Wn t k
 r‚ t |  _ n
 Xt |  _ d  S(   Nu    (   t   superR
   t   __init__t   copied_filest   symlinked_filest   unmodified_filest   post_processed_filesR   t   storageR   t   stylet   patht   NotImplementedErrort   Falset   localt   True(   t   selft   argst   kwargs(    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyR      s    					c         C  s  | j  d d d d d d d t d d	 ƒ| j  d
 d d d d d t d d ƒ| j  d d d d d g  d d d d d d ƒ| j  d d d d d d d t d d ƒ| j  d d d d d d d t d d ƒ| j  d d d d d d d t d d  ƒ| j  d! d d d d" d t d d# ƒd  S($   Nu	   --noinputu
   --no-inputt   actionu   store_falset   destu   interactivet   defaultt   helpu-   Do NOT prompt the user for input of any kind.u   --no-post-processu   post_processu$   Do NOT post process collected files.u   -iu   --ignoreu   appendu   ignore_patternst   metavaru   PATTERNu`   Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.u   -nu	   --dry-runu
   store_trueu   dry_runu+   Do everything except modify the filesystem.u   -cu   --clearu   clearu[   Clear the existing files using the storage before trying to copy or link the original file.u   -lu   --linku   linku7   Create a symbolic link to each file instead of copying.u   --no-default-ignoreu   use_default_ignore_patternsuI   Don't ignore the common private glob-style patterns 'CVS', '.*' and '*~'.(   t   add_argumentR   R   (   R   t   parser(    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyt   add_arguments&   s*    c         K  s‘   | d |  _  | d |  _ | d |  _ | d |  _ | d |  _ | d } | d rk | d d	 d
 g 7} n  t t | ƒ ƒ |  _ | d |  _ d S(   uA   
        Set instance variables based on an options dict
        u   interactiveu	   verbosityu   linku   clearu   dry_runu   ignore_patternsu   use_default_ignore_patternsu   CVSu   .*u   *~u   post_processN(	   t   interactivet	   verbosityt   symlinkt   cleart   dry_runt   listt   sett   ignore_patternst   post_process(   R   t   optionsR*   (    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyt   set_options@   s    

c         C  s  |  j  r" |  j r" t d ƒ ‚ n  |  j r; |  j d ƒ n  |  j  rP |  j } n	 |  j } t ƒ  } x­ t ƒ  D]¢ } x™ | j	 |  j
 ƒ D]… \ } } t | d d ƒ r¾ t j j | j | ƒ } n | } | | k ró | | f | | <| | | | ƒ q… |  j d | d d ƒq… Wql W|  j rèt |  j d ƒ rè|  j j | d |  j ƒ} x | D]’ \ } }	 }
 t |
 t ƒ rš|  j j d	 | ƒ |  j j d ƒ |
 ‚ n  |
 rÐ|  j d
 | |	 f d d ƒ|  j j | ƒ qO|  j d | ƒ qOWn  i |  j |  j d 6|  j d 6|  j d 6S(   ux   
        Perform the bulk of the work of collectstatic.

        Split off from handle() to facilitate testing.
        u&   Can't symlink to a remote destination.u    u   prefixuÆ   Found another file with the destination path '%s'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.t   leveli   u   post_processR'   u   Post-processing '%s' failed!u   Post-processed '%s' as '%s'u   Skipped post-processing '%s'u   modifiedu
   unmodifiedu   post_processedN(   R%   R   R   R&   t	   clear_dirt	   link_filet	   copy_fileR   R   R(   R*   t   getattrt   Nonet   osR   t   joint   prefixt   logR+   t   hasattrR   R'   t
   isinstancet	   Exceptiont   stderrt   writeR   t   appendR   R   R   (   R   t   handlert   found_filest   finderR   R   t   prefixed_patht	   processort   original_patht   processed_patht	   processed(    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyt   collectO   sJ    						
c   
      K  sæ  |  j  |   d g } |  j r/ | j d ƒ n  | j d ƒ |  j ƒ  rt |  j j rt |  j j } | j d | ƒ n d  } | j d ƒ |  j r  | j d ƒ n | j d ƒ | j d ƒ |  j rí t	 d	 j
 | ƒ ƒ d
 k rí t d ƒ ‚ n  |  j ƒ  } t | d ƒ } t | d ƒ } t | d ƒ } |  j d k râd } | i | d 6d | d k r`d	 n d d 6|  j rwd n d d 6| rŽd | n d	 d 6| d r©d | n d	 d 6| d rÄd | pÇd	 d 6}	 |  j j |	 ƒ n  d  S(   Nu   
uG   You have activated the --dry-run option so no files will be modified.

ud   You have requested to collect static files at the destination
location as specified in your settingsu   :

    %s

u   .

u-   This will DELETE ALL FILES in this location!
u$   This will overwrite existing files!
uN   Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: u    u   yesu"   Collecting static files cancelled.u   modifiedu
   unmodifiedu   post_processedi   u^   
%(modified_count)s %(identifier)s %(action)s%(destination)s%(unmodified)s%(post_processed)s.
u   modified_countu   static fileu   su
   identifieru	   symlinkedu   copiedu   actionu    to '%s'u   destinationu   , %s unmodifiedu   , %s post-processed(   R-   R'   R=   t   is_local_storageR   t   locationR3   R&   R#   R	   R5   R   RF   t   lenR$   R%   t   stdoutR<   (
   R   R,   t   messaget   destination_patht	   collectedt   modified_countt   unmodified_countt   post_processed_countt   templatet   summary(    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyt   handleŽ   sF    		
	$
i   c         C  s&   |  j  | k r" |  j j | ƒ n  d S(   u"   
        Small log helper
        N(   R$   RJ   R<   (   R   t   msgR.   (    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyR7   Ä   s    c         C  s   t  |  j t ƒ S(   N(   R9   R   R   (   R   (    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyRG   Ë   s    c         C  sJ  |  j  j | ƒ s d S|  j  j | ƒ \ } } xè | D]à } t j j | | ƒ } |  j ry |  j d t | ƒ d d ƒq5 |  j d t | ƒ d d ƒy |  j  j | ƒ } Wn! t	 k
 rÏ |  j  j
 | ƒ q5 Xt j j | ƒ rt j j | ƒ rt j | ƒ q5 |  j  j
 | ƒ q5 Wx* | D]" } |  j t j j | | ƒ ƒ q Wd S(   uX   
        Deletes the given relative path using the destination storage backend.
        Nu   Pretending to delete '%s'R.   i   u   Deleting '%s'(   R   t   existst   listdirR4   R   R5   R'   R7   R   R   t   deletet   lexistst   unlinkR/   (   R   R   t   dirst   filest   ft   fpatht	   full_patht   d(    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyR/   Î   s$    		%c         C  s€  |  j  j | ƒ r|y |  j  j | ƒ } Wn t t t f k
 rD n÷ Xy | j | ƒ } Wn t t t f k
 rt nÇ X|  j r“ |  j  j | ƒ } n d } | j	 d d ƒ | j	 d d ƒ k r;|  j
 rß | rß t j j | ƒ pþ |  j
 oþ | oþ t j j | ƒ s;| |  j k r#|  j j | ƒ n  |  j d | ƒ t Sn  |  j rX|  j d | ƒ q||  j d | ƒ |  j  j | ƒ n  t S(   uR   
        Checks if the target file should be deleted if it already exists
        t   microsecondi    u   Skipping '%s' (not modified)u   Pretending to delete '%s'u   Deleting '%s'N(   R   RU   t   modified_timet   OSErrorR   t   AttributeErrorR   R   R3   t   replaceR%   R4   t   islinkR   R=   R7   R   R'   RW   R   (   R   R   RA   t   source_storaget   target_last_modifiedt   source_last_modifiedR^   (    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyt   delete_fileê   s6    		c         C  s§  | |  j  k r  |  j d | ƒ S|  j | | | ƒ s9 d S| j | ƒ } |  j rk |  j d | d d ƒn|  j d | d d ƒ|  j j | ƒ } y t j t j j | ƒ ƒ Wn t	 k
 rÄ n Xy6 t j j
 | ƒ rê t j | ƒ n  t j | | ƒ Wnƒ t k
 r0d d l } t d | j ƒ  ƒ ‚ nQ t k
 rbd d l } t d	 | j ƒ  ƒ ‚ n t	 k
 r€} t | ƒ ‚ n X| |  j  k r£|  j  j | ƒ n  d S(
   u*   
        Attempt to link ``path``
        u&   Skipping '%s' (already linked earlier)Nu   Pretending to link '%s'R.   i   u   Linking '%s'iÿÿÿÿu)   Symlinking is not supported by Python %s.u2   Symlinking is not supported in this platform (%s).(   R   R7   Ri   R   R'   R   R4   t   makedirst   dirnameRb   RX   RY   R%   Rc   t   platformR   t   python_versionR   R=   (   R   R   RA   Rf   t   source_pathR^   Rl   t   e(    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyR0     s:    	c         C  sÁ   | |  j  k r  |  j d | ƒ S|  j | | | ƒ s9 d S| j | ƒ } |  j rk |  j d | d d ƒnB |  j d | d d ƒ| j | ƒ  } |  j j | | ƒ Wd QX|  j  j | ƒ d S(   u7   
        Attempt to copy ``path`` with storage
        u&   Skipping '%s' (already copied earlier)Nu   Pretending to copy '%s'R.   i   u   Copying '%s'(	   R   R7   Ri   R   R'   t   openR   t   saveR=   (   R   R   RA   Rf   Rn   t   source_file(    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyR1   =  s    	(   t   __name__t
   __module__t   __doc__R   R   t   requires_system_checksR   R"   R-   RF   RS   R7   RG   R/   Ri   R0   R1   (    (    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyR
      s   				?	6			,	'(   t
   __future__R    R4   t   collectionsR   t"   django.contrib.staticfiles.findersR   t"   django.contrib.staticfiles.storageR   t   django.core.files.storageR   t   django.core.management.baseR   R   t   django.core.management.colorR   t   django.utils.encodingR   t   django.utils.six.movesR	   R
   (    (    (    sŠ   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyt   <module>   s   