
    h!;                         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        [        5       U l	        g N)
super__init__copied_filessymlinked_filesunmodified_filespost_processed_filesr   storager
   style)selfargskwargs	__class__s      n/var/www/html/env/lib/python3.13/site-packages/django/contrib/staticfiles/management/commands/collectstatic.pyr   Command.__init__   sE    $)&)! "$&!*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_runr/   r4   staticfilesr-   N)r)   r:   symlinkr<   r=   r   get_app_configr/   listosr"   normpathr-   )r   optionsr/   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       Hl  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                  SU-  SS9  Mn     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 R,                  R/                  S
U-  5        U R,                  R/                  5         U
eU
(       a6  U R                  SU< SU	< S3SS9  U R0                  R3                  U5        M  U R                  SU-  5        M     U R4                  U R6                  -   U R8                  U R0                  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)r?   r%   r	   r<   	clear_dir	link_file	copy_filer   rA   r/   getattrrB   r"   joinrI   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.collectk   s    <<

GHH::NN2<<nnGnnG!mF!'T-A-A!B7Hd33$&GGLL$FM$(M 329K.D9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                 Z   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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
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.rJ   rO   rP   rQ   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*   destinationrP   rQ    )rF   r=   r.   is_local_storager   locationexistsanylistdirr)   r<   inputrV   r	   re   r:   lenr?   )	r   rD   messagedestination_pathshould_warn_user	collectedrm   unmodified_countpost_processed_counts	            r   handleCommand.handle   s    #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 :!67N"9\#:;#&y1A'B#C C #1+^q5HrcR)-+85EJ!112 !. &(88 ./ E-0DD 	 r   c                 \    U R                   U:  a  U R                  R                  U5        gg)z
Small log helper
N)r:   stdoutr\   )r   msgrL   s      r   rW   Command.log   s'     >>U"KKc" #r   c                 6    [        U R                  [        5      $ r   )rY   r   r   r$   s    r   rq   Command.is_local_storage   s    $,,(9::r   c                 8   U R                   R                  U5      (       d  gU R                   R                  U5      u  p#U H  n[        R                  R                  X5      nU R                  (       a  U R                  SU-  SS9  MH  U R                  SU-  SS9   U R                   R	                  U5      n[        R                  R                  U5      (       d<  [        R                  R                  U5      (       a  [        R                  " U5        M  U R                   R                  U5        M     U H1  nU R                  [        R                  R                  X5      5        M3     g! [         a     U R                   R                  U5         GMW  f = f)zG
Delete the given relative path using the destination storage backend.
NPretending to delete '%s'rJ   rK   Deleting '%s')r   rs   ru   rB   r"   rV   r=   rW   lexistsunlinkdeleter#   rR   )r   r"   dirsfilesffpath	full_pathds           r   rR   Command.clear_dir   s)    ||""4((ll**40AGGLL)E||4u<AF50:	3 $ 1 1% 8I 77>>)449S9S		),++E2   ANN277<<01  + /LL''../s   E//%FFc                 P   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     Nmf = f! [        [        [        4 a     Nf = f)zB
Check if the target file should be deleted if it already exists.
Tr   )microsecondzSkipping '%s' (not modified)Fr   r   )r   rs   get_modified_timer%   r"   r?   rB   islinkreplacer   r.   rW   OSErrorr#   AttributeErrorr=   r   )	r   r"   r`   source_storagetarget_last_modifiedsource_last_modifiedr   can_skip_unmodified_filesfile_is_unmodifieds	            r   delete_fileCommand.delete_file  s}    <<}--%%'+||'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  !4nE  0.A 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'rJ   rK   zLinking '%s'rN   T)exist_okr   z2Symlinking is not supported in this platform (%s).)r   rW   r   r"   r=   r   rB   makedirsdirnamer   r   r?   r#   platformr	   r   r.   )r   r"   r`   r   source_pathr   r   es           r   rS   Command.link_fileE  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'rJ   rK   zCopying '%s'rN   )	r   rW   r   r"   r=   openr   saver.   )r   r"   r`   r   r   source_files         r   rT   Command.copy_fileh  s    
 ---88DtKLL^DD$))$/<<HH.<AHFHH^k1H;$$T*k!!-= +  / +*s   C
C$)r<   r   r=   r/   r)   r-   r   r   r   r?   r   r   r:   )rN   )__name__
__module____qualname____firstlineno____doc__r,   r   r>   requires_system_checksr   r   r%   r7   rF   re   r~   rW   rq   rR   r   rS   rT   __static_attributes____classcell__)r   s   @r   r   r      st    
 8D"../   3
j4=
~AF#;261f!7F0 0r   r   )rB   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   rp   r   r   <module>r      s.    	  : B # 7 A 1 3n0k n0r   