[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.116.8.68: ~ $
�

>�Dg�/����UdZddlmZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZmZmZmZmZmZmZmZmZdd	lmZddlZd
dlmZmZd
dl m!Z!d
d
l"m#Z#d
dl$m%Z%m&Z&d
dl'm(Z(erddl)m*Z*ej+dej,��Z-de.d<ej/��Z0de.d<e0dzZ1de.d<d+d�Z2Gd�de3��Z4Gd�de4��Z5Gd�de4��Z6d,d"�Z7d-d$�Z8d%�Z9d&d'�d.d*�Z:dS)/zMigration router.�)�annotationsN)�cached_property)�
import_module)�Path)�
ModuleType)	�
TYPE_CHECKING�Any�Final�Iterable�List�Optional�Set�Type�Union)�mock�)�NEWLINE�	diff_many)�logger)�Migrator)�
MIGRATE_TABLE�MigrateHistory)�TEMPLATE)�Loggerz\s+$r
�CLEAN_RE�CURDIR�
migrations�DEFAULT_MIGRATE_DIRc��dS�N�)�m�d�fakes   �L/opt/imunify360/venv/lib64/python3.11/site-packages/peewee_migrate/router.py�voidr& s���4�c��eZdZdZeddefd2d�Zed3d���Ze	d4d���Z
e	d5d���Ze	d5d���Zed6d���Z
ddd�d7d�Zd8d9d�Zd�Z			d:d;d%�Zd9d&�Zd'ddd(�d<d.�Zd=dd/�d>d0�Zd1�ZdS)?�
BaseRouterzAbstract base class for router.N�database�Union[pw.Database, pw.Proxy]�ignore�Optional[Iterable[str]]�schema�
Optional[str]rrc���||_||_||_||_||_t|jtjtjf��std|z���dS)�Initialize the router.zInvalid database: %sN)
r*�
migrate_tabler.r,r�
isinstance�pw�Database�Proxy�	TypeError)�selfr*r2r,r.rs      r%�__init__zBaseRouter.__init__'sc��!��
�*�������������$�-�"�+�r�x�)@�A�A�	?��2�X�=�>�>�>�	?�	?r'�return�Type[MigrateHistory]c��tj}|j|_|j|_|j|_tjd���tS)z,Initialize and cache MigrationHistory model.T)�safe)r�_metar*r2�
table_namer.�create_table)r8�metas  r%�modelzBaseRouter.model8sB���#���
��
��,����k����#��.�.�.�.��r'�
Iterable[str]c��t�)zGet migrations to run.��NotImplementedError�r8s r%�todozBaseRouter.todoBs
��"�!r'�	List[str]c��d�|j����|jj��D��S)zScan migrations in database.c��g|]	}|j��
Sr!��name)�.0�mms  r%�
<listcomp>z#BaseRouter.done.<locals>.<listcomp>Js��N�N�N�B���N�N�Nr')rB�select�order_by�idrGs r%�donezBaseRouter.doneGs9��O�N�$�*�"3�"3�"5�"5�">�">�t�z�}�"M�"M�N�N�N�Nr'c�R��t|j����fd�|jD��S)z'Calculate difference between fs and db.c���g|]}|�v�|��	Sr!r!)rNrMrTs  �r%rPz#BaseRouter.diff.<locals>.<listcomp>Ps#���?�?�?��d�$�.>�.>��.>�.>�.>r')�setrTrH)r8rTs @r%�diffzBaseRouter.diffLs.����4�9�~�~��?�?�?�?���?�?�?�?r'rc�n�t|j��}|jD]}|�||���|S)z2Create migrator and setup it with fake migrations.)rr*rT�run_one)r8�migratorrMs   r%r[zBaseRouter.migratorRs@���D�M�*�*���I�	)�	)�D��L�L��x�(�(�(�(��r'�autoF)r\rM�strr	c�X��dx}}|�rTtj�t���t	|t
��r|n|g}t
d�|D����sv	|}t	|t��r%d�tj	t�g��D��}d�|D��}n,#t$r�j�d|��YdSwxYw�j
r�fd�|D��}�jD]}��|�jd�	��� t#�j|��}|s�j�d
��dSt#�j|d���}�j�d|����|||��}�j�d
|��|S)zYCreate a migration.

        :param auto: Python module path to scan for models.
        �c3�4K�|]}t|��V��dSr )�_check_model)rNr"s  r%�	<genexpr>z$BaseRouter.create.<locals>.<genexpr>ds(����7�7�1�|�A���7�7�7�7�7�7r'c��g|]
\}}}|�|��Sr!r!)rN�_r"�ispkgs    r%rPz%BaseRouter.create.<locals>.<listcomp>hs4��#�#�#�"-�!�Q��X]�#��#�#�#r'c�6�g|]}t|��D]}|���Sr!)�load_models)rN�moduler"s   r%rPz%BaseRouter.create.<locals>.<listcomp>ks-��S�S�S�F�{�6�?R�?R�S�S�!�a�S�S�S�Sr'zCan't import models module: %sNc�:��g|]}|jj�jv�|��Sr!)r>rMr,)rNr"r8s  �r%rPz%BaseRouter.create.<locals>.<listcomp>rs)���O�O�O��q�w�|�4�;�/N�/N�!�/N�/N�/Nr'T�r$zNo changes found.��reversezCreating migration "%s"z"Migration has been created as "%s")�sys�path�appendrr3�list�all�bool�pkgutil�iter_modules�ImportErrorr�	exceptionr,rXrZr[�compile_migrations�warning�info�compile)r8rMr\�migrate�rollback�models�modules�	migrations`       r%�createzBaseRouter.createZs����
 ���(��	O��H�O�O��M�*�*�*�'��d�3�3�?�T�T�$��F��7�7��7�7�7�7�7�
 �
 �$�G�!�$��-�-��#�#�18�1E�&�{�m�1T�1T�#�#�#��T�S�g�S�S�S�F�F��"� � � ��K�)�)�*J�D�Q�Q�Q��4�4� �����{�
P�O�O�O�O�V�O�O�O��!�Y�
B�
B�	����Y��
�D��A�A�A�A�(����?�?�G��
���#�#�$7�8�8�8��t�)�$�-���N�N�N�H�����2�D�9�9�9��|�|�D�'�8�4�4������=�t�D�D�D��s�"AB+�+%C�C�initialc��t|j��}t|t|jj����}|s|j�d��S|���|j�	d|��t|jg��}|�
|||d��}t|j��}|�||dd���|j�	d|��dS)zMerge migrations into one.zCan't merge migrationszMerge migrations into "%s"rT�r$�forcez$Migrations has been merged into "%s"N)rr*rwrpr[�ormr�error�clearryrzrZ)r8rMr[r{r|s     r%�mergezBaseRouter.merge�s����D�M�*�*��$�X�t�D�M�4E�/F�/F�G�G���	?��;�$�$�%=�>�>�>��
�
��������5�t�<�<�<�%�d�m�R�8�8���|�|�D�'�8�Q�7�7���D�M�*�*�����T�8�$�d��;�;�;�����?��F�F�F��tr'c�\�|j������dS)zClear migrations.N)rB�delete�executerGs r%r�zBaseRouter.clear�s(���
�����#�#�%�%�%�%�%r'r_r{r|�num�
Optional[int]c��t�)�Create a migration.rE)r8rMr{r|r�s     r%rzzBaseRouter.compile�s
��"�!r'c��t�)�Read migration from file.rE)r8rMs  r%�readzBaseRouter.read�s��!�!r'T)r$�	downgrader�r[r$rrr�r�c��	|�|��\}}|r�tj��}d|j_tjd��5tjd|���5|||j|���ddd��n#1swxYwYddd��n#1swxYwY|r6|j�|���|j	�
d|��g|_|S|j���5|sT|j	�
d|��|||j|���|��|j�|���n�|j	�
d	|��|||j|���|��|j�
���|jj|k�����|j	�
d|��|cddd��S#1swxYwYdS#t"$r=|j���|sd
nd}	|j	�d|	|���wxYw)
z(Run/emulate a migration with given name.Nzpeewee.Model.selectzpeewee.Database.execute_sql)�return_valuerjrLzDone %szMigrate "%s"zRolling back %s�	Migration�Rollbackz
%s failed: %s)r�r�Mock�	fetch_oner��patchr*rBr�rry�__ops__�transactionr��whererMr��	Exceptionr|rv)
r8rMr[r$r�r�r{r|�
mocked_cursor�	operations
          r%rZzBaseRouter.run_one�sX��$	� $�	�	�$����G�X��

� $�	���
�7;�
�'�4��Z� 5�6�6�@�@��
�1�
�9�9�9�@�@��G�H�d�m�$�?�?�?�?�@�@�@�@�@�@�@�@�@�@�@����@�@�@�@�@�@�@�@�@�@�@�@�@�@�@����@�@�@�@�
�6��J�%�%�4�%�0�0�0��K�$�$�Y��5�5�5�#%�� �����*�*�,�,�

�

� �	Q��K�$�$�^�T�:�:�:��G�H�d�m�$�?�?�?�?��H�J�J�J��J�%�%�4�%�0�0�0�0��K�$�$�%6��=�=�=��H�X�t�}�4�@�@�@�@��H�J�J�J��J�%�%�'�'�-�-�d�j�o��.E�F�F�N�N�P�P�P��� � ��D�1�1�1��

�

�

�

�

�

�

�

�

�

�

�

����

�

�

�

�

�

���	�	�	��M�"�"�$�$�$�+4�D���*�I��K�!�!�/�9�d�C�C�C��		���s��A
H�B�&B�:B�B
	�
B�
B
	�B�H�B!�!H�$B!�%AH�)H�C7H�9H�H
�
H�
H
�H�AIrjc	��|j�d��g}|j}|s|j�d��|S|j}|D]8}|�|�||||�����|r||krn�9|S)zRun migrations.zStarting migrationszThere is nothing to migrater�)rryrXr[rorZ)r8rMr$rTrXr[�mnames       r%�runzBaseRouter.run�s�������.�/�/�/����y���	��K���:�;�;�;��K��=���	�	�E��K�K����U�H�4�t��L�L�M�M�M��
���
�
�����r'c��|j}|sd}t|���|d}|j}|�||dd���|j�d|��dS)zRollback the latest migration.zThere is nothing to rollback���FT)r$r�zDowngraded migration: %sN)rT�RuntimeErrorr[rZrrx)r8rT�msgrMr[s     r%r|zBaseRouter.rollback�sm���y���	$�0�C��s�#�#�#��B�x���=�����T�8�%�4��@�@�@�����6��=�=�=�=�=r')r*r+r,r-r.r/rr)r:r;)r:rC)r:rI)r:r)rMr]r\r	r:r/)r�)rMr]�r_r_N)
rMr]r{r]r|r]r�r�r:r])rMr]r[rr$rrr�rrr�rrr:r]r )rMr/r$rrr:rI)�__name__�
__module__�__qualname__�__doc__rrr9rrB�propertyrHrTrXr[r�r�r�rzr�rZr�r|r!r'r%r)r)$s�������)�)�
$�*.� $��
?�?�?�?�?�"�����_���"�"�"��X�"��O�O�O��X�O��@�@�@��X�@�
�����_��'��'�'�'�'�'�'�R�����$&�&�&���!�"�"�"�"�"�"�"�"�"����.�.�.�.�.�.�`�e�������$
>�
>�
>�
>�
>r'r)c�x��eZdZdZejd��Z	dd�fd�
Zed���Z	ddd�Zd�Z
�fd
�Z�xZS)�RouterzFile system router.z[\d]{3}_[^\.]+\.py$N�migrate_dir�Optional[Union[str, Path]]c���tt|��j|fi|��|�t}n$t	|t
��rt
|��}||_dS�r1N)�superr�r9rr3r]rr�)r8r*r��kwargs�	__class__s    �r%r9zRouter.__init__�sd���	%��f�d���$�X�8�8��8�8�8���-�K�K�
��S�
)�
)�	,��{�+�+�K�&����r'c����j���s;�j�d�j���j�d���t�fd�t
j�j��D����S)zScan migrations in file system.z'Migration directory: %s does not exist.T)�parentsc3�`�K�|](}�j�|���|dd�V��)dS)N���)�filemask�match)rN�fr8s  �r%rbzRouter.todo.<locals>.<genexpr>sA�����]�]��d�m�FY�FY�Z[�F\�F\�]�a����f�]�]�]�]�]�]r')r��existsrrx�mkdir�sorted�os�listdirrGs`r%rHzRouter.todo	s������&�&�(�(�	1��K��� I�4�K[�\�\�\���"�"�4�"�0�0�0��]�]�]�]�b�j��1A�&B�&B�]�]�]�]�]�]r'r_r:r]c�4�|�t|j��}d�|dz��|z}|dz}|j|z}|�d��5}|�t
j|||�����ddd��n#1swxYwY|S)r�Nz{:03}_r�.py�w)r{r|rM)�lenrH�formatr��open�writer)r8rMr{r|r��filenamernr�s        r%rzzRouter.compiles����;��d�i�.�.�C����s�Q�w�'�'�$�.���%�<����(�*��
�Y�Y�s�^�^�	X�q�
�G�G�H�O�G�h�X�V�V�V�W�W�W�	X�	X�	X�	X�	X�	X�	X�	X�	X�	X�	X����	X�	X�	X�	X��s�+B
�
B�Bc�Z�|j|dzz}|�d��5}|���}i}t|ddd���}t	||d��|�dt��|�d	t��fcddd��S#1swxYwYdS)
r�r��rz<string>�execT)�dont_inheritNr{r|)r�r�r�rzr��getr&)r8rMrnr��code�scopes      r%r�zRouter.reads�����4�%�<�0��
�Y�Y�s�^�^�	K�q��6�6�8�8�D��E��4��V�$�G�G�G�D���u�d�#�#�#��9�9�Y��-�-�u�y�y��T�/J�/J�J�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K����	K�	K�	K�	K�	K�	Ks�A0B � B$�'B$c���tt|�����|jD]#}|j|dzz}|����$dS)zRemove migrations from fs.r�N)r�r�r�rHr��unlink)r8rMrnr�s   �r%r�zRouter.clear(sZ���
�f�d���!�!�#�#�#��I�	�	�D��#�t�e�|�4�D��K�K�M�M�M�M�	�	r'r )r�r�r�)r:r])
r�r�r�r��rerzr�r9r�rHr�r��
__classcell__�r�s@r%r�r��s�����������r�z�0�1�1�H�
37�'�'�'�'�'�'�'��^�^��X�^������K�K�K���������r'r�c�*��eZdZdZd�fd�	Zd�Z�xZS)�ModuleRouterzModule based router.rc���tt|��j|fi|��t|t��rt|��}||_dSr�)r�r�r9r3r]r�migrate_module)r8r*r�r�r�s    �r%r9zModuleRouter.__init__3sU���*��l�D�!�!�*�8�>�>�v�>�>�>��n�c�*�*�	;�*�>�:�:�N�,����r'c��t|j|��}t|dt��t|dt��fS)zRead migrations from a module.r{r|)�getattrr�r&)r8rM�mods   r%r�zModuleRouter.read<s7���d�)�4�0�0���s�I�t�,�,�g�c�:�t�.L�.L�L�Lr')r)r�r�r�r�r9r�r�r�s@r%r�r�0sY���������-�-�-�-�-�-�M�M�M�M�M�M�Mr'r�rh�Union[str, ModuleType]r:�Set[Type[pw.Model]]c�h�t|t��r|gnt|��}d�|D��S)zLoad models from given module.c	�v��h|]5�tt�fd�t���D����D]}|���6S)c3�8�K�|]}t�|��V��dSr )r�)rNrMrhs  �r%rbz(load_models.<locals>.<setcomp>.<genexpr>Is-�����&U�&U��w�v�t�'<�'<�&U�&U�&U�&U�&U�&Ur')�filterra�dir)rNr"rhs  @r%�	<setcomp>zload_models.<locals>.<setcomp>Fse���������&U�&U�&U�&U��V���&U�&U�&U�V�V���
�	
����r')r3r�_import_submodules)rhr~s  r%rgrgBsI��%�V�Z�8�8�X�v�h�h�>P�QW�>X�>X�G�������r'.c��|durt��}t|t��rt|��}t	|d��s|hSg}t|j��|zr|S|t|j��z}t
j|j|jdz��D]i\}}}|�	|d��}|�|j
��&|j
�|��}|�|��|r|t|��z
}�j|S)N.�__path__�.)rWr3r]r�hasattrr�rs�
walk_packagesr��	find_spec�loader�load_moduleror�)�package�passedr~r�rM�is_pkg�specrhs        r%r�r�Ms!��
��}�}������'�3���)���(�(���7�J�'�'���y���G�
�7����v�%����
�c�'�"�#�#�#�F� '� 5�g�6F��HX�[^�H^� _� _�2�2����f�����d�+�+���<�4�;�.����(�(��.�.�����v�����	2��)�&�1�1�1�G���Nr'c��t|t��o)t|tj��ot|d��S)z/Check object if it's a peewee model and unique.r>)r3�type�
issubclassr4�Modelr�)�objs r%rarais3���c�4� � �X�Z��R�X�%>�%>�X�7�3�PW�CX�CX�Xr'Frkr[rc��t|j��}|r||}}t||||���}|sdSttjd�|���d����z}t�d|��S)z$Compile migrations for given models.rkr_z

�
)rpr�rr�join�splitr�sub)r[r}rl�sourcerr�s      r%rwrwns���
�(�,�
�
�F��(������6�6�8�W�E�E�E�J����r��W�\�&�+�+�j�"9�"9�"?�"?��"E�"E�F�F�F�D��<�<��d�#�#�#r'r )rhr�r:r�).)r[r);r��
__future__rr�rsr�rm�	functoolsr�	importlibr�pathlibr�typesr�typingrr	r
rrr
rrr�unittestr�peeweer4r\rr�logsrr[rr}rr�templater�loggingrrz�Mr�__annotations__�cwdrrr&�objectr)r�r�rgr�rarwr!r'r%�<module>r
s������"�"�"�"�"�"�	�	�	�	�����	�	�	�	�
�
�
�
�%�%�%�%�%�%�#�#�#�#�#�#�������������X�X�X�X�X�X�X�X�X�X�X�X�X�X�X�X�X�X�X�X�X�X�����������$�$�$�$�$�$�$�$�������������1�1�1�1�1�1�1�1����������������"�*�W�b�d�+�+��+�+�+�+����
�
������#�l�2��2�2�2�2�����O>�O>�O>�O>�O>��O>�O>�O>�d7�7�7�7�7�Z�7�7�7�tM�M�M�M�M�:�M�M�M�$��������8Y�Y�Y�
?D�$�$�$�$�$�$�$�$r'

Filemanager

Name Type Size Permission Actions
__init__.cpython-311.pyc File 401 B 0644
__main__.cpython-311.pyc File 379 B 0644
auto.cpython-311.pyc File 19.25 KB 0644
cli.cpython-311.pyc File 9.98 KB 0644
logs.cpython-311.pyc File 538 B 0644
migrator.cpython-311.pyc File 25.16 KB 0644
models.cpython-311.pyc File 1.22 KB 0644
router.cpython-311.pyc File 22.03 KB 0644
template.cpython-311.pyc File 1.83 KB 0644
types.cpython-311.pyc File 675 B 0644