
    3~h                     J    d dl Z d dlmZ ddlmZ ddlmZmZ  G d de      Zy)    N)BaseCommand   )MissingSource)cachefile_registrygenerator_registryc                   ,    e Zd ZdZdZd Zd Zd Zd Zy)Commanda  Generate files for the specified image generators (or all of them if
none was provided). Simple, glob-like wildcards are allowed, with *
matching all characters within a segment, and ** matching across
segments. (Segments are separated with colons.) So, for example,
"a:*:c" will match "a:b:c", but not "a:b:x:c", whereas "a:**:c" will
match both. Subsegments are always matched, so "a" will match "a" as
well as "a:b" and "a:b:c".z[generator_ids]c                 ,    |j                  ddd       y )Ngenerator_id*z*<app_name>:<model>:<field> for model specs)nargshelp)add_argument)selfparsers     t/var/www/peopleoo.sandbox-dev.co.uk/venv/lib/python3.12/site-packages/imagekit/management/commands/generateimages.pyadd_argumentszCommand.add_arguments   s    N#<hi    c                 J   t        j                         }d|v r|d   n|}|r| j                  |      fd|D        }|D ]  }| j                  j	                  d|z         t        j                  |      D ]H  }|j                  s| j                  j	                  d|j                  z         	 |j                          J  y # t        $ r%}| j                  j	                  d       Y d }~wd }~wt        $ r(}| j                  j	                  d|z         Y d }~d }~ww xY w)Nr   c              3   N   K   | ]  t        fd D              s  yw)c              3   @   K   | ]  }|j                          y wN)match).0pids     r   	<genexpr>z+Command.handle.<locals>.<genexpr>.<genexpr>   s     8W8Ws   N)any)r   r   patternss    @r   r   z!Command.handle.<locals>.<genexpr>   s     XS8Wh8W5W"Xs   %%zValidating generator: %s
z  %s
z	 No source associated with
z	Failed %s
)r   get_idscompile_patternsstdoutwriter   getnamegenerater   	Exception)	r   argsoptions
generatorsgenerator_idsr   
image_fileerrr   s	           @r   handlezCommand.handle   s	   '//1
3AW3L/RV,,];HXzXJ& 
	CLKK:\IJ044\B C
??KK%%h&@AC"++-	C
	C ) L))*JKK$ C))/S*ABBCs$   0C	D"C..D":DD"c                 J    |D cg c]  }| j                  |       c}S c c}w r   )compile_pattern)r   r+   r   s      r   r!   zCommand.compile_patterns*   s!    3@AR$$R(AAAs    c                     t        j                  d|      }d}|D ]0  }|dk(  r|dz  }|dk(  r|dz  }|t        j                  |      z  }2 t        j                  d|z        S )Nz	(\*{1,2}) r   z[^:]*z**z.*z
^%s(:.*)?$)resplitescapecompile)r   r   partspatternparts        r   r0   zCommand.compile_pattern-   so    |4 	+Ds{7"4299T?*	+ zz,011r   N)	__name__
__module____qualname__r   r(   r   r.   r!   r0    r   r   r	   r	   	   s'    D DjC(B
2r   r	   )	r3   django.core.management.baser   
exceptionsr   registryr   r   r	   r=   r   r   <module>rA      s    	 3 ' >.2k .2r   