
    Evg!;                         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
 d dlmZmZ d dlmZ d d	lmZ  G d
 de          ZdS )    N)apps)get_finders)staticfiles_storage)Tags)FileSystemStorage)BaseCommandCommandError)no_style)cached_propertyc                        e Zd ZdZdZej        gZ fdZe	d             Z
d Zd Zd Zd Zdd
Zd Zd Zd Zd Zd Z xZS )Commandzc
    Copies or symlinks static files from different locations to the
    settings.STATIC_ROOT.
    z*Collect static files in a single location.c                      t                      j        |i | g | _        g | _        g | _        g | _        t          | _        t                      | _	        d S N)
super__init__copied_filessymlinked_filesunmodified_filespost_processed_filesr   storager
   style)selfargskwargs	__class__s      y/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyr   zCommand.__init__   sU    $)&)))! "$&!*ZZ


    c                 `    	 | j                             d           n# t          $ r Y dS w xY wdS )N FT)r   pathNotImplementedErrorr   s    r   localzCommand.local   sG    	Lb!!!!" 	 	 	55	ts    
++c           	      l   |                     ddddd           |                     dddd	           |                     d
ddg ddd           |                     dddd           |                     dddd           |                     dddd           |                     dddd           d S )Nz	--noinputz
--no-inputstore_falseinteractivez-Do NOT prompt the user for input of any kind.)actiondesthelpz--no-post-processpost_processz$Do NOT post process collected files.z-iz--ignoreappendignore_patternsPATTERNz`Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.)r'   defaultr(   metavarr)   z-nz	--dry-run
store_truez+Do everything except modify the filesystem.)r'   r)   z-cz--clearz[Clear the existing files using the storage before trying to copy or link the original file.z-lz--linkz7Create a symbolic link to each file instead of copying.z--no-default-ignoreuse_default_ignore_patternszWDon't ignore the common private glob-style patterns (defaults to 'CVS', '.*' and '*~').)add_argument)r   parsers     r   add_argumentszCommand.add_arguments'   sI    @ 	 	
 	
 	
 	 7	 	 	
 	
 	
 	": 	 		
 		
 		
 	>	 	 	
 	
 	
 	?	 	 	
 	
 	
 	J	 	 	
 	
 	
 	! .) 	 	
 	
 	
 	
 	
r   c                 6   |d         | _         |d         | _        |d         | _        |d         | _        |d         | _        |d         }|d         r|t          j        d          j        z  }t          d	 |D                       | _        |d
         | _	        dS )zA
        Set instance variables based on an options dict
        r&   	verbositylinkcleardry_runr,   r1   staticfilesc                 L    h | ]!}t           j                            |          "S  )osr    normpath).0ps     r   	<setcomp>z&Command.set_options.<locals>.<setcomp>h   s(    $R$R$RQRW%5%5a%8%8$R$R$Rr   r*   N)
r&   r6   symlinkr8   r9   r   get_app_configr,   listr*   )r   optionsr,   s      r   set_optionszCommand.set_options\   s     #=1 -vW%
y)!"3401 	Rt2=AAQQO#$R$R/$R$R$RSS#N3r   c                    | j         r| j        st          d          | j        r|                     d           | j         r| j        }n| j        }i }t                      D ]}|                    | j	                  D ]q\  }}t          |dd          r&t          j                            |j        |          }n|}||vr||f||<    ||||           W|                     d|z  d           r| j        rt#          | j        d          r| j                            || j        	          }|D ]\  }}	}
t)          |
t*                    r8| j                            d
|z             | j                                         |
|
r9|                     d|d|	dd           | j                            |           |                     d|z             | j        | j        z   | j        | j        dS )zx
        Perform the bulk of the work of collectstatic.

        Split off from handle() to facilitate testing.
        z&Can't symlink to a remote destination.r   prefixNzFound 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.   levelr*   )r9   zPost-processing '%s' failed!zPost-processed 'z' as ''   zSkipped post-processing '%s')modified
unmodifiedpost_processed)rB   r#   r	   r8   	clear_dir	link_file	copy_filer   rD   r,   getattrr=   r    joinrH   logr*   hasattrr   r9   
isinstance	Exceptionstderrwriter   r+   r   r   r   )r   handlerfound_filesfinderr    r   prefixed_path	processororiginal_pathprocessed_path	processeds              r   collectzCommand.collectk   sp    < 	I
 	IGHHH: 	NN2< 	%nGGnG!mm 	 	F!'T-A!B!B  g7Hd33 )$&GLL$F$FMM$(M 33294K.GD-9999HH? BOO       (  	M~!F!F 	M11+t|1TTI<E M M8~yi33 $K%%&D}&TUUU K%%'''#O MHHH9FW     -44]CCCCHH;mKLLLL )D,@@/"7
 
 	
r   c                     | j         di | dg}| j        r|                    d           |                    d           |                                 rr| j        j        rf| j        j        }|                    d|z             | j                            |          o&t          | j                            |                    }nd }|                    d           d}| j	        r~|r|| j
        r|                    d           n|                    d           |                    d	           t          d
                    |                    dk    rt          d          |                                 }| j        dk    rt!          |d                   }t!          |d                   }t!          |d                   }d|d|dk    rd
ndz   | j        rdnd|rd|z  nd
|d         rd|z  nd
|d         rd|z  pd
dz  S d S )N
zGYou have activated the --dry-run option so no files will be modified.

zdYou have requested to collect static files at the destination
location as specified in your settingsz:

    %s

z.

Tz-This will DELETE ALL FILES in this location!
z$This will overwrite existing files!
zNAre you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: r   yesz"Collecting static files cancelled.rI   rN   rO   rP   z]
%(modified_count)s %(identifier)s %(action)s%(destination)s%(unmodified)s%(post_processed)s.zstatic files	symlinkedcopiedz to '%s'z, %s unmodifiedz, %s post-processed)modified_count
identifierr'   destinationrO   rP   r<   )rF   r9   r+   is_local_storager   locationexistsanylistdirr&   r8   inputrU   r	   rd   r6   lenrB   )	r   rE   messagedestination_pathshould_warn_user	collectedrk   unmodified_countpost_processed_counts	            r   handlezCommand.handle   s   ##7###&< 	NN   
 	5	
 	
 	

   "" 
	$t|'< 
	$#|4NN,/??@@@#|223CDD  $$%566J J  $NN7#### 	I 0 	Iz HOPPPPFGGGNN>   RWWW%%&&%//"#GHHHLLNN	>Q :!677N"9\#:;;#&y1A'B#C#C C #1+^q5H5HrrcR)-C++85EMJ!1112 !.%(888 ./ E-0DD  	 r   rM   c                 T    | j         |k    r| j                            |           dS dS )z"
        Small log helper
        N)r6   stdoutr[   )r   msgrK   s      r   rV   zCommand.log   s5     >U""Kc""""" #"r   c                 6    t          | j        t                    S r   )rX   r   r   r"   s    r   rn   zCommand.is_local_storage   s    $,(9:::r   c                    | j                             |          sdS | j                             |          \  }}|D ]}t          j                            ||          }| j        r|                     d|z  d           E|                     d|z  d           	 | j                             |          }t          j                            |          s4t          j                            |          rt          j	        |           | j         
                    |           # t          $ r | j         
                    |           Y w xY w|D ]5}|                     t          j                            ||                     6dS )zW
        Delete the given relative path using the destination storage backend.
        NPretending to delete '%s'rI   rJ   Deleting '%s')r   rp   rr   r=   r    rU   r9   rV   lexistsunlinkdeleter!   rQ   )r   r    dirsfilesffpath	full_pathds           r   rQ   zCommand.clear_dir   s    |""4(( 	Fl**400e 	3 	3AGLLq))E| 34u<AFFFF50:::	3 $ 1 1% 8 8I 7>>)44 39S9S 3	),,,,++E2222 + / / /L''...../  	2 	2ANN27<<a001111	2 	2s   D$$$EEc                 .   | j                             |          ry	 | j                             |          }	 |                    |          }| j        rC| j                             |          }| j        t          j                            |          z   }nd}|                    d          |                    d          k    }|r?|r=|| j	        vr| j	        
                    |           |                     d|z             dS n:# t          t          t          f$ r Y n!w xY w# t          t          t          f$ r Y nw xY w| j        r|                     d|z             n2|                     d|z             | j                             |           dS )zR
        Check if the target file should be deleted if it already exists.
        Tr   )microsecondzSkipping '%s' (not modified)Fr   r   )r   rp   get_modified_timer#   r    rB   r=   islinkreplacer   r+   rV   OSErrorr!   AttributeErrorr9   r   )	r   r    r_   source_storagetarget_last_modifiedsource_last_modifiedr   can_skip_unmodified_filesfile_is_unmodifieds	            r   delete_filezCommand.delete_file  s    <}-- ,	3%%'+|'E'Em'T'T$
%+9+K+KD+Q+Q(
 z 9$(L$5$5m$D$D	 !L27>>)+D+DD511 591)=)E)E$% *F * *-55!5DD*E& * %.G %(0EEE 188GGG!?$!FGGG$u7  !4nE   D 0.A   H | 34t;<<<<4/000##M222ts"   D& D	 	D#"D#&E ?E c                 :   || j         v r|                     d|z            S |                     |||          sdS |                    |          }| j        r|                     d|z  d           n|                     d|z  d           | j                            |          }t          j        t          j                            |          d	           	 t          j        	                    |          rt          j
        |           t          j        ||           nR# t          $ r) d
dl}t          d|                                z            t          $ r}t          |          d}~ww xY w|| j         vr| j                             |           dS dS )z*
        Attempt to link ``path``
        z&Skipping '%s' (already linked earlier)NzPretending to link '%s'rI   rJ   zLinking '%s'rM   T)exist_okr   z2Symlinking is not supported in this platform (%s).)r   rV   r   r    r9   r   r=   makedirsdirnamer   r   rB   r!   platformr	   r   r+   )r   r    r_   r   source_pathr   r   es           r   rR   zCommand.link_fileE  s   
 D00088DtKLLLm^DD 	F$))$//< 	&HH.<AHFFFFHH^k1H;;;))-88IK	22TBBBB&7??9-- )Ii(((
;	2222&   "%'/'8'8':':;    & & &"1oo%& 444 ''66666 54s   AD$ $;E3E..E3c                    || j         v r|                     d|z            S |                     |||          sdS |                    |          }| j        r|                     d|z  d           nb|                     d|z  d           |                    |          5 }| j                            ||           ddd           n# 1 swxY w Y   | j                             |           dS )z7
        Attempt to copy ``path`` with storage
        z&Skipping '%s' (already copied earlier)NzPretending to copy '%s'rI   rJ   zCopying '%s'rM   )	r   rV   r   r    r9   openr   saver+   )r   r    r_   r   r   source_files         r   rS   zCommand.copy_fileh  s;   
 D---88DtKLLLm^DD 	F$))$//< 	>HH.<AHFFFFHH^k1H;;;$$T** >k!!-===> > > > > > > > > > > > > > >  /////s   !C		CC)rM   )__name__
__module____qualname____doc__r)   r   r:   requires_system_checksr   r   r#   r4   rF   rd   r{   rV   rn   rQ   r   rR   rS   __classcell__)r   s   @r   r   r      s        
 8D"./            _3
 3
 3
j4 4 4=
 =
 =
~A A AF# # # #; ; ;2 2 261 1 1f!7 !7 !7F0 0 0 0 0 0 0r   r   )r=   django.appsr   "django.contrib.staticfiles.findersr   "django.contrib.staticfiles.storager   django.core.checksr   django.core.files.storager   django.core.management.baser   r	   django.core.management.colorr
   django.utils.functionalr   r   r<   r   r   <module>r      s    				       : : : : : : B B B B B B # # # # # # 7 7 7 7 7 7 A A A A A A A A 1 1 1 1 1 1 3 3 3 3 3 3n0 n0 n0 n0 n0k n0 n0 n0 n0 n0r   