
    g:                         d dl Z 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 d dlmZ ddlmZmZ dd	Zd
 ZddZd Zd Zd Zd Zd Zd Z e       xZfdZy)    N)Path)run)appsget_random_string)DEFAULT_LOCALE_ENCODING   )CommandErrorCommandParserc                    	 t        | dt        j                  dk7        }|j
                  j                  |      |j                  j                  t        d      |j                  fS # t        $ r}t	        d| d   z        |d}~ww xY w)	zf
    Friendly wrapper around Popen.

    Return stdout output, stderr output, and OS status code.
    Tnt)capture_output	close_fdszError executing %sr   Nreplace)errors)
r   osnameOSErrorr
   stdoutdecodestderrr   
returncode)argsstdout_encodingperrs       t/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/core/management/utils.pypopen_wrapperr      s    DTRWW_E 	
(	/	B	   D/$q'9:CDs   A( (	B1BBc                     g }| D ]2  }|j                  |j                  dd      j                  d             4 t        |      D ]"  \  }}|j	                  d      rd||   z  ||<   $ t        |      S )a  
    Organize multiple extensions that are separated with commas or passed by
    using --extension/-e multiple times.

    For example: running 'django-admin makemessages -e js,txt -e xhtml -a'
    would result in an extension list: ['.js', '.txt', '.xhtml']

    >>> handle_extensions(['.html', 'html,js,py,py,py,.py', 'py,.py'])
    {'.html', '.js', '.py'}
    >>> handle_extensions(['.html, txt,.tpl'])
    {'.html', '.tpl', '.txt'}
      ,.z.%s)extendr   split	enumerate
startswithset)
extensionsext_listextis       r   handle_extensionsr-       sr     HC,22378 H%3~~c"(1+-HQK & x=    c                 V   |=t         j                  j                  dd      j                  t         j                        }t        |t              r|g}|=t         j                  j                  dd      j                  t         j                        }|D ]  }| j                  |      sdg} n |D ]v  }t         j                  j                  ||       }t         j                  j                  |      r|c S |D ],  }||z   }t         j                  j                  |      s(|c c S  x y )NPATHr!   PATHEXTz.COM;.EXE;.BAT;.CMD)r   environgetr%   pathsep
isinstancestrendswithpathjoinisfile)cmdr8   pathextr+   r   ffexts          r   find_commandr?   6   s    |zz~~fb)//

;$v**..,ABHHT<<dG 
 GGLLC 77>>!HCs7Dww~~d# 	  r.   c                      d} t        d|       S )zS
    Return a 50 character random string usable as a SECRET_KEY setting value.
    z2abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)2   r   )charss    r   get_random_secret_keyrC   O   s     AER''r.   c                 f   t               }t               }| D ]U  }d|v r(	 t        j                  |      }|j                  |       /	 t        j                  |      }|j                  |       W ||fS # t        $ r t	        d|z        w xY w# t        $ r}t	        t        |            d}~ww xY w)z
    Parse a list of "app_label.ModelName" or "app_label" strings into actual
    objects and return a two-element tuple:
        (set of model classes, set of app_configs).
    Raise a CommandError if some specified models or apps don't exist.
    r#   zUnknown model: %sN)r(   installed_apps	get_modelLookupErrorr
   addget_app_configr6   )labelsr   modelslabelmodel
app_configes          r   parse_apps_and_model_labelsrP   W   s     5DUF%<@&007 JJu++::5A
 HHZ   4<  @"#6#>??@  +"3q6**+s#   A3B3B	B0B++B0c                     t        dd      }|j                  |d       	 |j                  | dd       \  }}|j                  S # t        $ r Y yw xY w)z
    Return the value of a command line option (which should include leading
    dashes, e.g. '--testrunner') from an argument list. Return None if the
    option wasn't passed or if the argument list couldn't be parsed.
    F)add_helpallow_abbrevvalue)dest   N)r   add_argumentparse_known_argsrT   r
   )argvoptionparseroptions_s        r   get_command_line_optionr^   r   sb     E>F
W-,,T!"X6
 }}  s   A 	AAc                 ^   | D cg c]!  }t         j                  j                  |      # } }dt         j                  hD ch c]  }d|z  	 }}g }| D ]M  }|D ]5  }|j	                  |      s|j                  |j                  |              < |j                  |       O |S c c}w c c}w )z9Normalize an iterable of glob style patterns based on OS./z%s*)r   r8   normcasesepr7   appendremovesuffix)patternsr   path_sepdir_suffixesnorm_patternspattern
dir_suffixs          r   normalize_path_patternsrk      s    -56X  #XH669266]C]EH$]LCM&J
+$$W%9%9*%EF '
   )   7Cs   &B%B*c                 `     t                 fdt        fdt        |      D              S )zy
    Check if the given path should be ignored or not based on matching
    one of the glob style `ignore_patterns`.
    c                     t        j                  j                  |       xs t        j                  t              |       S N)fnmatchfnmatchcaser   r6   )ri   r8   s    r   ignorezis_ignored_path.<locals>.ignore   s7    ""499g6 
':M:MIw;
 	
r.   c              3   .   K   | ]  } |        y wrn    ).0ri   rq   s     r   	<genexpr>z"is_ignored_path.<locals>.<genexpr>   s     W.V7vg.Vs   )r   anyrk   )r8   ignore_patternsrq   s   ` @r   is_ignored_pathrx      s,    
 :D

 W.Eo.VWWWr.   c                  0    dt        j                  d      iS )N
black_pathblack)shutilwhichrs   r.   r   find_formattersr~      s    &,,w/00r.   c                 |    |t         u rt        j                  d      }|rt        j                  |ddg| d       yy)z9
    Run the black formatter on the specified files.
    r{   z--fastz--T)r   N)sentinelr|   r}   
subprocessr   )written_filesrz   s     r   run_formattersr      s@    
 X\\'*
48-8	
 r.   )zutf-8)NN)ro   r   r|   r   pathlibr   r   django.appsr   rE   django.utils.cryptor   django.utils.encodingr   baser
   r   r   r-   r?   rC   rP   r^   rk   rx   r~   objectr   r   rs   r.   r   <module>r      sc     	     . 1 9 -",2(6 X1 ;A(.Bh 
r.   