/usr/local/lib/python3.9/site-packages/django/contrib/auth/management/__pycache__
a Ӱ�hr � @ s� d Z ddlZddlZddlmZ ddlmZ ddlm Z ddl mZ ddlm Z mZ dd � Zd d� Zdd e efdd�Zdd� Zd e fdd�ZdS )zC Creates permissions for all installed apps that need permissions. � N)�apps)�get_permission_codename)�create_contenttypes)� exceptions)�DEFAULT_DB_ALIAS�routerc C s g t | ��| j�S )zH Return (codename, name) for all permissions in the given opts. )�_get_builtin_permissionsZpermissions)�opts� r �Q/usr/local/lib/python3.9/site-packages/django/contrib/auth/management/__init__.py�_get_all_permissions s r c C s2 g }| j D ]"}|�t|| �d|| jf f� q |S )z� Return (codename, name) for all autogenerated permissions. By default, this is ('add', 'change', 'delete', 'view') z Can %s %s)Zdefault_permissions�appendr Zverbose_name_raw)r �perms�actionr r r r s ��r � Tc K sr | j s d S t| f||||d�|�� | j}z&|�|�} |�dd�}|�dd�}W n tyd Y d S 0 t�||�svd S g } t� } | � � D ]B}|j �|�j|dd�}| � |� t|j�D ]} | �|| f� q�q�t|j �|�j| d��d d ��}g }| D ]D\}\}}|j|f|vr�|� }||j_||_||_||_|�|� q�|j �|��|� |dk�rn|D ]} td| � �qZd S ) N)� verbosity�interactive�usingr Zcontenttypes�ContentType�auth� PermissionF)Zfor_concrete_model)Zcontent_type__in�content_type�codenamer zAdding permission '%s')Z models_moduler �labelZget_app_configZ get_model�LookupErrorr Zallow_migrate_model�setZ get_models�objects� db_managerZ get_for_model�addr �_metar r �filterZvalues_list�pk�_state�dbr �namer Zbulk_create�print)Z app_configr r r r �kwargsZ app_labelr r Zsearched_perms�ctypes�klass�ctype�permZ all_permsr �ctr r$ Z permissionr r r �create_permissions% sd ��� � ��� r, c C s* zt �� } W n ttfy$ Y dS 0 | S )zt Return the current system user's username, or an empty string if the username could not be determined. � )�getpass�getuser�ImportError�KeyError)�resultr r r �get_system_usernamer s r3 c C s� ddl m} |jjjrdS t� }z*t�d|��dd�� d�� dd��� }W n ty^ Y dS 0 z|jj� d��|� W n tjy� Y dS 0 | r�|r�z|jj�|�j|d � W n |jjy� Y n0 dS |S ) a� Try to determine the current system user's username to use as a default. :param check_db: If ``True``, requires that the username does not match an existing ``auth.User`` (otherwise returns an empty string). :param database: The database where the unique check will be performed. :returns: The username, or an empty string if no username can be determined or the suggested username is already taken. r )�modelsr- ZNFKD�ascii�ignore� �username)r8 )�django.contrib.authr4 ZUserr Zswappedr3 �unicodedata� normalize�encode�decode�replace�lower�UnicodeDecodeError� get_fieldZrun_validatorsr ZValidationErrorZ_default_managerr �getZDoesNotExist)Zcheck_dbZdatabaseZauth_appZdefault_usernamer r r �get_default_username� s8 ����� rC )�__doc__r. r: Zdjango.appsr Zglobal_appsr9 r Z&django.contrib.contenttypes.managementr Zdjango.corer Z django.dbr r r r r, r3 rC r r r r �<module> s � M
.
Edit
..
Edit
__init__.cpython-39.pyc
Edit