HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/django/core/management/__pycache__/utils.cpython-310.pyc
o

�a	�@s�ddlZddlZddlmZddlmZmZddlmZ	ddl
mZddlm
Z
ddlmZmZdd
d�Zdd
�Zddd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�N)�Path)�PIPE�run)�apps��get_random_string)�DEFAULT_LOCALE_ENCODING�)�CommandError�
CommandParser�utf-8c
Csfz
t|tttjdkd�}Wnty"}z	td|d�|�d}~ww|j�|�|jjt	dd�|j
fS)zf
    Friendly wrapper around Popen.

    Return stdout output, stderr output, and OS status code.
    �nt)�stdout�stderr�	close_fdszError executing %srN�replace)�errors)rr�os�name�OSErrorr
r�decoderr�
returncode)�args�stdout_encoding�p�err�r�>/usr/lib/python3/dist-packages/django/core/management/utils.py�
popen_wrapper
s��
�rcCsZg}|D]}|�|�dd��d��qt|�D]\}}|�d�s(d||||<qt|�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�irrr�handle_extensionss

�r,cCs�|durtj�dd��tj�}t|t�r|g}|dur&tj�dd��tj�}|D]}|�|�r4dg}nq(|D](}tj�	||�}tj�
|�rJ|S|D]}||}tj�
|�r^|SqLq7dS)N�PATHr �PATHEXTz.COM;.EXE;.BAT;.CMD)r�environ�getr$�pathsep�
isinstance�str�endswith�path�join�isfile)�cmdr5�pathextr*r�f�fextrrr�find_command4s,

���r<cCsd}td|�S)zS
    Return a 50 character random string usable as a SECRET_KEY setting value.
    z2abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)�2r)�charsrrr�get_random_secret_keyMs
r?cCs�t�}t�}|D]@}d|vr)zt�|�}Wn
ty"td|��w|�|�qzt�|�}WntyB}ztt|���d}~ww|�|�q||fS)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"zUnknown model: %sN)r'�installed_apps�	get_model�LookupErrorr
�add�get_app_configr3)�labelsr�models�label�model�
app_config�errr�parse_apps_and_model_labelsUs$���rKcCsNtddd�}|j|dd�z|�|dd��\}}W|jSty&YdSw)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_argsr
rN)�argv�option�parser�options�_rrr�get_command_line_optionps��rXcCsndd�|D�}dd�dtjhD�}g}|D]}|D]}|�|�r.|�|dt|���nq|�|�q|S)z9Normalize an iterable of glob style patterns based on OS.cSsg|]}tj�|��qSr)rr5�normcase)�.0rrrr�
<listcomp>�sz+normalize_path_patterns.<locals>.<listcomp>cSsh|]}d|�qS)z%s*r)rZ�path_seprrr�	<setcomp>�sz*normalize_path_patterns.<locals>.<setcomp>�/N)r�sepr4�append�len)�patterns�dir_suffixes�
norm_patterns�pattern�
dir_suffixrrr�normalize_path_patterns�s
�
�rgcs.t����fdd��t�fdd�t|�D��S)zy
    Check if the given path should be ignored or not based on matching
    one of the glob style `ignore_patterns`.
    cst��j|�pt�t��|�S�N)�fnmatch�fnmatchcaserr3)re)r5rr�ignore�szis_ignored_path.<locals>.ignorec3s�|]}�|�VqdSrhr)rZre)rkrr�	<genexpr>�s�z"is_ignored_path.<locals>.<genexpr>)r�anyrg)r5�ignore_patternsr)rkr5r�is_ignored_path�sro)r)NN)rir�pathlibr�
subprocessrr�django.appsrr@�django.utils.cryptor�django.utils.encodingr�baser
rrr,r<r?rKrXrgrorrrr�<module>s