https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/db/migrations/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/db/migrations/__pycache__/questioner.cpython-310.pyc
o

3�a�&�@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZGdd�d�ZGd	d
�d
e�Z
Gdd�de�ZdS)
�N)�apps��NOT_PROVIDED)�timezone�)�MigrationLoaderc@sReZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�MigrationQuestionerz�
    Give the autodetector responses to questions it might have.
    This base class has a built-in noninteractive mode, but the
    interactive subclass is what the command-line arguments will use.
    NcCs |pi|_|p	t�|_||_dS�N)�defaults�set�specified_apps�dry_run)�selfr
rr
�r�A/usr/lib/python3/dist-packages/django/db/migrations/questioner.py�__init__s

zMigrationQuestioner.__init__cCs�||jvrdSzt�|�}Wnty|j�dd�YSwt�|j�\}}|dur2|j�dd�Szt	�
|�}WntyI|j�dd�YSwt|dd�r[t
�t
j�|j��}nt|d�rst|j�dkridSt
�t|j�d�}td	d
�|D��S)z2Should we create an initial migration for the app?T�ask_initialFN�__file__�__path__rrcss"�|]}|dkr|�d�VqdS)z__init__.pyz.pyN)�endswith)�.0�xrrr�	<genexpr>6s� z2MigrationQuestioner.ask_initial.<locals>.<genexpr>)rr�get_app_config�LookupErrorr
�getr�migrations_module�label�	importlib�
import_module�ImportError�getattr�os�listdir�path�dirnamer�hasattr�lenr�list�any)r�	app_label�
app_config�migrations_import_path�_r�	filenamesrrrrs,
��
zMigrationQuestioner.ask_initialcC�dS)�#Adding a NOT NULL field to a model.Nr�r�
field_name�
model_namerrr�ask_not_null_addition8�z)MigrationQuestioner.ask_not_null_additioncCr/)�"Changing a NULL field to NOT NULL.Nrr1rrr�ask_not_null_alteration=r5z+MigrationQuestioner.ask_not_null_alterationcC�|j�dd�S)�Was this field really renamed?�
ask_renameF�r
r)rr3�old_name�new_name�field_instancerrrr:B�zMigrationQuestioner.ask_renamecCr8)�Was this model really renamed?�ask_rename_modelFr;)r�old_model_state�new_model_staterrrrAFr?z$MigrationQuestioner.ask_rename_modelcCr8)z-Do you really want to merge these migrations?�	ask_mergeFr;�rr*rrrrDJr?zMigrationQuestioner.ask_mergecCr/)�(Adding an auto_now_add field to a model.Nrr1rrr�ask_auto_now_add_additionNr5z-MigrationQuestioner.ask_auto_now_add_addition)NNN)�__name__�
__module__�__qualname__�__doc__rrr4r7r:rArDrGrrrrr
s
rc@sXeZdZddd�Zdd�Zddd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�ZdS)�InteractiveMigrationQuestionerNcCs\td|�}|s|dur|S|r|d��dvr&td�}|r|d��dvs|d��dkS)Nz%s r�ynzPlease answer yes or no: �y)�input�lower)r�question�default�resultrrr�_boolean_inputVs�z-InteractiveMigrationQuestioner._boolean_inputcCs~t|�t|�D]\}}td|d|f�qtd�}	zt|�}Wn	ty+Ynwd|kr9t|�kr:|Std�}q)Nz %s) %srzSelect an option: TrzPlease select a valid option: )�print�	enumeraterO�int�
ValueErrorr')rrQ�choices�i�choicerS�valuerrr�
_choice_input^s���z,InteractiveMigrationQuestioner._choice_input�c
Cs�td�|r
td�|��td�td�	|rd�|�}nd}t|�}|s*|r*|}|s1td�n/|d	kr;t�d
�n%z
t|ittd��WStt	fy_}ztd|�WYd
}~nd
}~wwq)z�
        Prompt for a default value.

        The ``default`` argument allows providing a custom default value (as a
        string) which will be shown to the user and used as the return value
        if the user doesn't provide any other input.
        z3Please enter the default value now, as valid PythonzUYou can accept the default '{}' by pressing 'Enter' or you can provide another value.z]The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.nowzType 'exit' to exit this promptTz[default: {}] >>> z>>> z;Please enter some code, or 'exit' (with no quotes) to exit.�exitr)�datetimerzInvalid input: %sN)
rU�formatrO�sysr_�evalr`r�SyntaxError�	NameError)rrR�prompt�code�errr�_ask_defaultms4�
���z+InteractiveMigrationQuestioner._ask_defaultcCs@|js|�d||fddg�}|dkrt�d�dS|��SdS)r0z�You are trying to add a non-nullable field '%s' to %s without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:�bProvide a one-off default now (will be set on all existing rows with a null value for this column)�+Quit, and let me add a default in models.py��N)r
r]rbr_ri�rr2r3r[rrrr4�s���

�z4InteractiveMigrationQuestioner.ask_not_null_additioncCsL|js$|�d||fgd��}|dkrtS|dkr t�d�dS|��SdS)r6z�You are trying to change the nullable field '%s' on %s to non-nullable without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:)rjz�Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration)rkrlrmN)r
r]rrbr_rirnrrrr7�s��
�z6InteractiveMigrationQuestioner.ask_not_null_alterationcCs"d}|�||||||jjfd�S)r9z+Did you rename %s.%s to %s.%s (a %s)? [y/N]F)rT�	__class__rH)rr3r<r=r>�msgrrrr:�s��z)InteractiveMigrationQuestioner.ask_renamecCs d}|�||j|j|jfd�S)r@z+Did you rename the %s.%s model to %s? [y/N]F)rTr*�name)rrBrCrprrrrA�s��z/InteractiveMigrationQuestioner.ask_rename_modelcCs|�dd�S)Nz�
Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Do you want to merge these migration branches? [y/N]F)rTrErrrrD�s�z(InteractiveMigrationQuestioner.ask_mergecCsD|js |�d�||�ddg�}|dkrt�d�dS|jdd�SdS)	rFz�You are trying to add the field '{}' with 'auto_now_add=True' to {} without a default; the database needs something to populate existing rows.
z@Provide a one-off default now (will be set on all existing rows)rkrlrmztimezone.now)rRN)r
r]rarbr_rirnrrrrG�s��

�z8InteractiveMigrationQuestioner.ask_auto_now_add_additionr	)r^)rHrIrJrTr]rir4r7r:rArDrGrrrrrLTs

"rLc@s$eZdZdd�Zdd�Zdd�ZdS)�!NonInteractiveMigrationQuestionercC�t�d�dS�Nrm�rbr_r1rrrr4�r?z7NonInteractiveMigrationQuestioner.ask_not_null_additioncCstSr	rr1rrrr7�sz9NonInteractiveMigrationQuestioner.ask_not_null_alterationcCrsrtrur1rrrrG�r?z;NonInteractiveMigrationQuestioner.ask_auto_now_add_additionN)rHrIrJr4r7rGrrrrrr�srr)r`rr"rb�django.appsr�django.db.modelsr�django.utilsr�loaderrrrLrrrrrr�<module>sG

https://t.me/RX1948 - 2025