
    jg                     l    d dl Z d dl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
mZ  G d de      Zd Zy)	    N)List)
AppCommand)color_style)_make_writeablesignalcommandc                   L     e Zd ZU dZg Zee   ed<   dZ fdZ	e
d        Z xZS )CommandzfCreates a Django management command directory structure for the given app name in the app's directory.requires_system_checksTc                     t         |   |       |j                  dddddd       |j                  dd	dd
dd       |j                  dddd       y )Nz--namez-nstorecommand_namesamplez*The name to use for the management command)actiondestdefaulthelpz--basez-bbase_commandBasezdThe base class used for implementation of this command. Should be one of Base, App, Label, or NoArgsz	--dry-run
store_trueFz Do not actually create any files)r   r   r   )superadd_argumentsadd_argument)selfparser	__class__s     o/var/www/html/Stanley/venv/lib/python3.12/site-packages/django_extensions/management/commands/create_command.pyr   zCommand.add_arguments   sx    f%d7= 	 	

 	d7 "I 	 	

 	e3 	 	
    c                 6    |}t        d|j                  fi | y )Ncommand_template)copy_templatepath)r   argsoptionsapps       r   handle_app_configzCommand.handle_app_config&   s    (#((>g>r   )__name__
__module____qualname__r   r
   r   str__annotations__can_import_settingsr   r   r%   __classcell__)r   s   @r   r	   r	      s8    sD(*DI* 
" ? ?r   r	   c           
         ddl }t               }t        |dd       }t        |dd       }|d   d|d	   z  }}|d
   }	|d   }
t        j                  j                  |j                  d   d|       }t        j                  |      D ]y  \  }}}|t        |      dz   d }|rrt        j                  j                  t        j                  j                  ||            s5|	s3t        j                  t        j                  j                  ||             t        |      D ]  \  }}|j                  d      s||=  |D ]  }|j                  d      s|j                  d      r't        j                  j                  ||      }t        j                  j                  |||j                  d|            j                  d      }t        j                  j                  |      rjt        j                  j                  |||      j                  d      }t        j                  j                  |      r|
dkD  rt!         |d|z               |
dkD  rt!         |d|z               t#        |d      5 }|j%                         }|j                  d|      }|j                  d|      }|	s&t#        |d      5 }|j'                  |       ddd       ddd       |	r	 t)        j*                  ||       t-        |        | y# 1 sw Y   >xY w# 1 sw Y   BxY w# t.        $ r& t0        j2                  j'                  d|z         Y w xY w)z=Copy the specified template directory to the copy_to locationr   NERRORc                     | S N xs    r   <lambda>zcopy_template.<locals>.<lambda>1   s    ar   SUCCESSc                     | S r0   r1   r2   s    r   r4   zcopy_template.<locals>.<lambda>2   s    !r   r   z	%sCommandr   dry_run	verbosityconf   .)z.pycz.pyo)z	.DS_Store__pycache__r   z.tmplz%s already existsz%srz{{ command_name }}z{{ base_command }}wzlNotice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.
)django_extensionsr   getattrosr!   join__path__walklenexistsmkdir	enumerate
startswithendswithreplacerstripprintopenreadwriteshutilcopymoder   OSErrorsysstderr)template_namecopy_tor#   r?   styler.   r5   r   r   r7   r8   template_dirdsubdirsfilesrelative_dirisubdirfpath_oldpath_newfp_origdatafp_news                           r   r    r    ,   s   MEE7K0EeY4G!(!8+P^H_:_,Li G$I77<< 1 : :1 =v}UL  WW\27E\*Q./0rww||G\/R Sg|<="7+IAv  %AJ , Azz*+q||<X/Yww||Aq)Hww||G\199X|;\]ddelmHww~~h'77<<qAHHQ77>>(+ 1}e$7($BCD1}gdXo./h$||~||$8,G||$8,Gh,T* - % aOOHh7#H-/  34 -, %$  aJJ$$  &U  X`  &`  aas7   1AL4L	L!LLLL+M
	M
)rA   rT   rQ   typingr   django.core.management.baser   django.core.management.colorr   "django_extensions.management.utilsr   r   r	   r    r1   r   r   <module>rj      s,    	 
   2 4 M?j ?>0ar   