
    fkib>                         S SK r S SKJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJrJr  S SKJr  S S	KJr   " S
 S\5      rg)    N)apps)get_finders)staticfiles_storage)Tags)FileSystemStorage)BaseCommandCommandError)no_style)cached_propertyc                      ^  \ rS rSrSrSr\R                  /rU 4S jr	\
S 5       rS rS rS rS	 rSS
 jrS rS rS rS rS rSrU =r$ )Command   zW
Copies or symlinks static files from different locations to the
settings.STATIC_ROOT.
z*Collect static files in a single location.c                    > [         TU ]  " U0 UD6  / U l        / U l        / U l        / U l        / U l        / U l        [        U l	        [        5       U l        g N)super__init__copied_filessymlinked_filesunmodified_filespost_processed_filesskipped_filesdeleted_filesr   storager
   style)selfargskwargs	__class__s      ځ/var/www/events.demo-site.click/venv/lib/python3.13/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyr   Command.__init__   sU    $)&)! "$&!*Z
    c                 \     U R                   R                  S5        g! [         a     gf = f)N FT)r   pathNotImplementedErrorr   s    r   localCommand.local!   s2    	LLb!  # 		s    
++c           
         UR                  SSSSSS9  UR                  SSSS	S9  UR                  S
SS/ SSSS9  UR                  SSSSS9  UR                  SSSSS9  UR                  SSSSS9  UR                  SSSSS9  g )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_argumentsCommand.add_arguments)   s     @ 	 	
 	 7	 	 	
 	": 	 		
 	>	 	 	
 	?	 	 	
 	J	 	 	
 	! .) 	 	
r!   c                 f   US   U l         US   U l        US   U l        US   U l        US   U l        US   nUS   (       a#  U[
        R                  " S5      R                  -  n[        U Vs1 s H"  n[        R                  R                  U5      iM$     sn5      U l        US	   U l        g
s  snf )z1
Set instance variables based on an options dict
r+   	verbositylinkcleardry_runr1   r6   staticfilesr/   N)r+   r<   symlinkr>   r?   r   get_app_configr1   listosr$   normpathr/   )r   optionsr1   ps       r   set_optionsCommand.set_options^   s     #=1 -vW%
y)!"3401t22=AQQQO#/$R/QRWW%5%5a%8/$RS#N3 %Ss   .)B.c                    U R                   (       a  U R                  (       d  [        S5      eU R                  (       a  U R	                  S5        U R                   (       a  U R
                  nOU R                  n0 n[        5        H  nUR                  U R                  5       H  u  pE[        USS5      (       a+  [        R                  R                  UR                  U5      nOUnXb;  a  XT4X&'   U" XFU5        MY  U R                  R!                  U5        U R#                  SU-  SS9  M     M     U R$                  (       a  ['        U R(                  S5      (       a  U R(                  R%                  X R*                  S	9nU H  u  pn
[-        U
[.        5      (       a:  U R0                  R3                  S
U-  5        U R0                  R3                  5         U
eU
(       a6  U R#                  SU< SU	< S3SS9  U R4                  R!                  U5        M  U R#                  SU-  5        M     U R6                  U R8                  -   U R:                  U R4                  U R                  U R<                  S.$ )z`
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/   )r?   zPost-processing '%s' failed!zPost-processed 'z' as ''zSkipped post-processing '%s')modified
unmodifiedpost_processedskippeddeleted)rA   r'   r	   r>   	clear_dir	link_file	copy_filer   rC   r1   getattrrD   r$   joinrK   r   r0   logr/   hasattrr   r?   
isinstance	Exceptionstderrwriter   r   r   r   r   )r   handlerfound_filesfinderr$   r   prefixed_path	processororiginal_pathprocessed_path	processeds              r   collectCommand.collectm   s    <<

GHH::NN2<<nnGnnG!mF!'T-A-A!B7Hd33$&GGLL$FM$(M 329K.D9&&--m<HH? BOO     "C $, ~!F!F11+||1TI<E8yi33KK%%&D}&TU KK%%'#OHH9FW   --44]CHH;mKL =F" ))D,@,@@//"77))))
 	
r!   c           
         U R                   " S 0 UD6  S/nU R                  (       a  UR                  S5        UR                  S5        U R                  5       (       a  U R                  R
                  (       aq  U R                  R
                  nUR                  SU-  5        U R                  R                  U5      =(       a$    [        U R                  R                  U5      5      nOS nUR                  S5        SnU R                  (       au  U(       an  U R                  (       a  UR                  S5        OUR                  S5        UR                  S	5        [        S
R                  U5      5      S:w  a  [        S5      eU R                  5       nU R                  S:  a  [!        US   5      n[!        US   5      n[!        US   5      n[!        US   5      n	[!        US   5      n
SUS:  a  U< SUS:X  a  S
OS< S3OS
USUS:X  a  S
OS-   U R"                  (       a  SOSU(       a  SU-  OS
US   (       a  SU-  OS
US   =(       a    SU	-  =(       d    S
US   (       a	  SU
-  S.-  $ S
S.-  $ g )!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.   rT   rP   rQ   rR   rS   zs
%(deleted)s%(modified_count)s %(identifier)s %(action)s%(destination)s%(unmodified)s%(post_processed)s%(skipped)s.r   z static filesz
 deleted, zstatic file	symlinkedcopiedz to '%s'z, %s unmodifiedz, %s post-processedz, %s skipped due to conflict)rT   modified_count
identifierr,   destinationrQ   rR   rS    )rH   r?   r0   is_local_storager   locationexistsanylistdirr+   r>   inputrY   r	   rh   r<   lenrA   )r   rF   messagedestination_pathshould_warn_user	collecteddeleted_countrq   unmodified_countpost_processed_countskipped_counts              r   handleCommand.handle   sl   #7#&<<NN 
 	5	

   ""t||'<'<#||44NN,/??@#||223CD  $$%56J  $NN7## 0zzOPFGNN> RWWW%&%/"#GHHLLN	>>Q	) 45M :!67N"9\#:;#&y1A'B#C 	) 45MN %q( %MQ,>bC&GI "0+^q5HrcR)-+85EJ!112 !. &(88 ./ E-0DD !+ 3]B1 : 5  r!   c                 \    U R                   U:  a  U R                  R                  U5        gg)z
Small log helper
N)r<   stdoutr_   )r   msgrN   s      r   rZ   Command.log   s'     >>U"KKc" #r!   c                 6    [        U R                  [        5      $ r   )r\   r   r   r&   s    r   ru   Command.is_local_storage  s    $,,(9::r!   c                    U R                   R                  U5      (       d  gU R                   R                  U5      u  p#U GH*  n[        R                  R                  X5      nU R                  (       a0  U R                  SU-  SS9  U R                  R                  U5        Md  U R                  SU-  SS9  U R                  R                  U5         U R                   R	                  U5      n[        R                  R                  U5      (       d=  [        R                  R                  U5      (       a  [        R                  " U5        GM  U R                   R                  U5        GM-     U H1  nU R                  [        R                  R                  X5      5        M3     g! [         a     U R                   R                  U5         GM  f = f)zG
Delete the given relative path using the destination storage backend.
NPretending to delete '%s'rL   rM   Deleting '%s')r   rw   ry   rD   r$   rY   r?   rZ   r   r0   lexistsunlinkdeleter%   rU   )r   r$   dirsfilesffpath	full_pathds           r   rU   Command.clear_dir	  sQ    ||""4((ll**40AGGLL)E||4u<AF""))%050:""))%0	3 $ 1 1% 8I 77>>)449S9S		),++E2# $ ANN277<<01  + /LL''../s   F((%GGc                 <   U R                   R                  U5      (       GaO   U R                   R                  U5      n UR                  U5      nU R                  (       aM  U R                   R	                  U5      nU R
                  [        R                  R                  U5      -  (       + nOSnUR                  SS9UR                  SS9:  nU(       aF  U(       a?  X R                  ;  a  U R                  R                  U5        U R                  SU-  5        gU R                  (       a  U R                  SU-  5        gU R                  SU-  5        U R                   R                  U5        g! [        [        4 a     Nhf = f! [        [        4 a     N~f = f)zB
Check if the target file should be deleted if it already exists.
Tr   )microsecondzSkipping '%s' (not modified)Fr   r   )r   rw   get_modified_timer'   r$   rA   rD   islinkreplacer   r0   rZ   OSErrorr%   r?   r   )	r   r$   rc   source_storagetarget_last_modifiedsource_last_modifiedr   can_skip_unmodified_filesfile_is_unmodifieds	            r   delete_fileCommand.delete_file&  sy    <<}--%%'+||'E'Em'T$
%+9+K+KD+Q(
 zz$(LL$5$5m$D	 !LL277>>)+DD51 591)=)E)E$% *F *-55!5D*E& *.G(0E0EE 1188G!?$!FG$||4t;<  4/0##M2E  !45  01 s"   F E2 2FFFFc                 *   X R                   ;   a  U R                  SU-  5      $ U R                  XU5      (       d  gUR                  U5      nU R                  (       a  U R                  SU-  SS9  OU R                  SU-  SS9  U R
                  R                  U5      n[        R                  " [        R                  R                  U5      SS	9   [        R                  R                  U5      (       a  [        R                  " U5        [        R                  " XE5        X R                   ;  a  U R                   R!                  U5        gg! [         a!    S
SKn[        SUR                  5       -  5      e[         a  n[        U5      eSnAff = f)z
Attempt to link ``path``
z&Skipping '%s' (already linked earlier)NzPretending to link '%s'rm   rM   zLinking '%s'rL   T)exist_okr   z2Symlinking is not supported in this platform (%s).)r   rZ   r   r$   r?   r   rD   makedirsdirnamer   r   rA   r%   platformr	   r   r0   )r   r$   rc   r   source_pathr   r   es           r   rV   Command.link_fileY  sO   
 00088DtKLL^DD$))$/<<HH.<AHFHH^k1H;))-8IKK	2TB&77??9--IIi(

;2  4 44  ''6 5 ' "%'/'8'8':;   &"1o%&s   AE 3FFFc                    X R                   ;   a  U R                  SU-  5      $ U R                  XU5      (       d  gUR                  U5      nU R                  (       a  U R                  SU-  SS9  OHU R                  SU-  SS9  UR                  U5       nU R                  R                  X%5        SSS5        U R                   R                  U5        g! , (       d  f       N*= f)z'
Attempt to copy ``path`` with storage
z&Skipping '%s' (already copied earlier)NzPretending to copy '%s'rm   rM   zCopying '%s'rL   )	r   rZ   r   r$   r?   openr   saver0   )r   r$   rc   r   r   source_files         r   rW   Command.copy_file|  s    
 ---88DtKLL^DD$))$/<<HH.<AHFHH^k1H;$$T*k!!-= +  / +*s   C
C$)r>   r   r   r?   r1   r+   r/   r   r   r   r   rA   r   r   r<   )rL   )__name__
__module____qualname____firstlineno____doc__r.   r   r@   requires_system_checksr   r   r'   r9   rH   rh   r   rZ   ru   rU   r   rV   rW   __static_attributes____classcell__)r   s   @r   r   r      su    
 8D"../	   3
j4@
DN`#;2:1f!7F0 0r!   r   )rD   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   rt   r!   r   <module>r      s.    	  : B # 7 A 1 3B0k B0r!   