403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.189.143.114
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/alembic/script/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/alembic/script/__pycache__/base.cpython-37.pyc
B

�M!V�i�@s�ddlZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZe�d	�Z
e�d
�Ze�d�Ze�d�Ze�d
�ZdZe�d�ZGdd�de�ZGdd�dej�ZdS)�N�)�util)�compat�)�revision)�	migration)�contextmanagerz(?!__init__)(.*\.py)(c|o)?$z(?!__init__)(.*\.py)$z([a-f0-9]+)\.py$z(upgrade|downgrade)_([a-z0-9]+)z\w+z%(rev)s_%(slug)sz,|(?: +)c@seZdZdZeddddfdd�Zedd	��Zej	d
d��Z
dd
�Zedd��Z
ed:dd��Zd;dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zed.d/��Zd0d1�Zd2d3�Zd4d5�Z d<d6d7�Z!d8d9�Z"dS)=�ScriptDirectoryaHProvides operations upon an Alembic script directory.

    This object is useful to get information as to current revisions,
    most notably being able to get at the "head" revision, for schemes
    that want to test if the current revision in the database is the most
    recent::

        from alembic.script import ScriptDirectory
        from alembic.config import Config
        config = Config()
        config.set_main_option("script_location", "myapp:migrations")
        script = ScriptDirectory.from_config(config)

        head_revision = script.get_current_head()



    �(NFzutf-8cCsV||_||_||_|pd|_||_||_t�|j�|_	t
�|t
j�sRt
�d|��dS)Nr
zVPath doesn't exist: %r.  Please use the 'init' command to create a new scripts folder.)�dir�
file_template�version_locations�truncate_slug_length�
sourceless�output_encodingrZRevisionMap�_load_revisions�revision_map�os�access�F_OKr�CommandError)�selfrrrr
rr�r�D/opt/alt/python37/lib/python3.7/site-packages/alembic/script/base.py�__init__*s
zScriptDirectory.__init__cCs*|j}t|�dkrt�d��n|dSdS)Nrz"Multiple version_locations presentr)�_version_locations�lenrr)r�locrrr�versions;szScriptDirectory.versionscCs4|jrdd�|jD�Stj�tj�|jd��fSdS)NcSsg|]}tj�t�|���qSr)r�path�abspathr�coerce_resource_to_filename)�.0�locationrrr�
<listcomp>Gsz6ScriptDirectory._version_locations.<locals>.<listcomp>r)r
rrr �joinr)rrrrrCs
z"ScriptDirectory._version_locationsccsd|jrdd�|jD�}n|jg}x>|D]6}x0t�|�D]"}t�|||�}|dkrRq6|Vq6Wq&WdS)NcSsg|]}tj�|�r|�qSr)rr�exists)r"�versrrrr$Psz3ScriptDirectory._load_revisions.<locals>.<listcomp>)r
rrr�listdir�Script�_from_filename)r�pathsr'Zfile_�scriptrrrrMs
zScriptDirectory._load_revisionsc	Cs�|�d�}|dkrt�d��|�d�}|dk	r6t|�}|�d�}|rNt�|�}tt�|�|�dt�||�d�dk|�d	d
�|d�S)z�Produce a new :class:`.ScriptDirectory` given a :class:`.Config`
        instance.

        The :class:`.Config` need only have the ``script_location`` key
        present.

        �script_locationNz0No 'script_location' key found in configuration.rr
rr�truerzutf-8)rrrrr
)	Zget_main_optionrr�int�_split_on_space_comma�splitr	r!�_default_file_template)�cls�configr-rr
rrr�from_config\s$	





zScriptDirectory.from_configc

csNydVW�n<tjk
rr}zF|dkr.|j}|dkr<|j}|sDd}|||d�}t�t�|��Wdd}~XYn�tjk
r�}z8|s�d}||p�|j	t�
|j�d�}t�t�|��Wdd}~XYn�tjk
�r}z&|dkr�d|j	}t�t�|��Wdd}~XYn<tj
k
�rH}	zt�t�|	jd��Wdd}	~	XYnXdS)NzgRequested range %(start)s:%(end)s does not refer to ancestor/descendant revisions along the same branch)�start�endz�Multiple head revisions are present for given argument '%(head_arg)s'; please specify a specific target revision, '<branchname>@%(head_arg)s' to narrow to a specific head, or 'heads' for all heads)Zhead_arg�headsz(Can't locate revision identified by '%s'r)rZRangeNotAncestorError�lower�upperrZraise_from_causerrZ
MultipleHeads�argument�format_as_commar8�ResolutionErrorZ
RevisionError�args)
r�ancestor�multiple_headsr6r7�
resolutionZrnaZmh�re�errrrr�_catch_revision_errors{s2   z&ScriptDirectory._catch_revision_errors�baser8c	csB|j||d��*x"|jj||ddd�D]
}|Vq&WWdQRXdS)a�Iterate through all revisions.

        :param base: the base revision, or "base" to start from the
         empty revision.

        :param head: the head revision; defaults to "heads" to indicate
         all head revisions.  May also be "head" to indicate a single
         head revision.

         .. versionchanged:: 0.7.0 the "head" identifier now refers to
            the head of a non-branched repository only; use "heads" to
            refer to the set of all head branches simultaneously.

        )r6r7TF)Z	inclusiveZassert_relative_lengthN)rDr�iterate_revisions)rrE�head�revrrr�walk_revisions�szScriptDirectory.walk_revisionsc	Cs |���|j�|�SQRXdS)z�Return the :class:`.Script` instance with the given rev identifier,
        symbolic name, or sequence of identifiers.

        .. versionadded:: 0.7.0

        N)rDr�
get_revisions)r�id_rrrrJ�s
zScriptDirectory.get_revisionsc	Cs |���|j�|�SQRXdS)z�Return the :class:`.Script` instance with the given rev id.

        .. seealso::

            :meth:`.ScriptDirectory.get_revisions`

        N)rDr�get_revision)rrKrrrrL�s	
zScriptDirectory.get_revisionc	Cs8|���|j�|�\}}WdQRX|s,dS|dSdS)z[Convert a symbolic revision, i.e. 'head' or 'base', into
        an actual revision number.Nr)rDrZ_resolve_revision_number)rrKrHZbranch_namerrr�as_revision_number�s

z"ScriptDirectory.as_revision_numbercCs|j�||�S)a�Iterate through script revisions, starting at the given
        upper revision identifier and ending at the lower.

        The traversal uses strictly the `down_revision`
        marker inside each migration script, so
        it is a requirement that upper >= lower,
        else you'll get nothing back.

        The iterator yields :class:`.Script` objects.

        .. seealso::

            :meth:`.RevisionMap.iterate_revisions`

        )rrF)rr:r9rrrrF�sz!ScriptDirectory.iterate_revisionsc	Cs"|jdd��|j��SQRXdS)aGReturn the current head revision.

        If the script directory has multiple heads
        due to branching, an error is raised;
        :meth:`.ScriptDirectory.get_heads` should be
        preferred.

        :return: a string revision number.

        .. seealso::

            :meth:`.ScriptDirectory.get_heads`

        z}The script directory has multiple heads (due to branching).Please use get_heads(), or merge the branches using alembic merge.)r@N)rDr�get_current_head)rrrrrN�s
z ScriptDirectory.get_current_headcCst|jj�S)aUReturn all "versioned head" revisions as strings.

        This is normally a list of length one,
        unless branches are present.  The
        :meth:`.ScriptDirectory.get_current_head()` method
        can be used normally when a script directory
        has only one head.

        :return: a tuple of string revision numbers.
        )�listrr8)rrrr�	get_headsszScriptDirectory.get_headscCs4|��}t|�dkr t�d��n|r,|dSdSdS)a#Return the "base" revision as a string.

        This is the revision number of the script that
        has a ``down_revision`` of None.

        If the script directory has multiple bases, an error is raised;
        :meth:`.ScriptDirectory.get_bases` should be
        preferred.

        rz@The script directory has multiple bases. Please use get_bases().rN)�	get_basesrrr)r�basesrrr�get_baseszScriptDirectory.get_basecCst|jj�S)z�return all "base" revisions as strings.

        This is the revision number of all scripts that
        have a ``down_revision`` of None.

        .. versionadded:: 0.7.0

        )rOrrR)rrrrrQ%s	zScriptDirectory.get_basesc	sN�jd|d��6�jj||dd�}t|�}�fdd�tt|��D�SQRXdS)NzFDestination %(end)s is not a valid upgrade target from current head(s))r?r7T)Z
implicit_basecsg|]}tj��j|��qSr)r�
MigrationStepZupgrade_from_scriptr)r"r,)rrrr$8sz1ScriptDirectory._upgrade_revs.<locals>.<listcomp>)rDrrFrO�reversed)r�destination�current_rev�revsr)rr�
_upgrade_revs0s

zScriptDirectory._upgrade_revsc	s:�jd|d��"�j�||�}�fdd�|D�SQRXdS)NzHDestination %(end)s is not a valid downgrade target from current head(s))r?r7csg|]}tj��j|��qSr)rrTZdowngrade_from_scriptr)r"r,)rrrr$Dsz3ScriptDirectory._downgrade_revs.<locals>.<listcomp>)rDrrF)rrVrWrXr)rr�_downgrade_revs=s

zScriptDirectory._downgrade_revsc	CsH|jdd���0|�|�}|jj||dd�}g}|�|�p>dg}x�|D]�}|dkrj|�dd�|D��qFn
||krtqFt|j�|g��}t|j�|g��}|�|�r�|�|�r�t	�dd�|D�}	t
�|	|jdd�}
|�
|
�qFqF|�|��rd	d�|D�}	t
�|	|jdd�}
|�
|
�qFqFt
�d
|jdd�}
|�
|
�qFqFW|SQRXdS)NzCMultiple heads are present; please specify a single target revision)r@T)Zinclude_dependenciescSsg|]}t�|jddd��qS)NFT)r�	StampStepr)r"rGrrrr$]sz/ScriptDirectory._stamp_revs.<locals>.<listcomp>cSsg|]
}|j�qSr)r)r"rGrrrr$osFcSsg|]
}|j�qSr)r)r"rGrrrr$wsr)rDrJrZfilter_for_lineage�extend�setZ_get_descendant_nodesZ_get_ancestor_nodes�intersection�AssertionErrorrr[r�append)rrr8Zfiltered_headsZstepsZdests�destZdescendantsZ	ancestorsZ
todo_heads�steprrr�_stamp_revsIsF






zScriptDirectory._stamp_revscCst�|jd�dS)z�Run the script environment.

        This basically runs the ``env.py`` script present
        in the migration environment.   It is called exclusively
        by the command functions in :mod:`alembic.command`.


        zenv.pyN)r�load_python_filer)rrrr�run_env�s	zScriptDirectory.run_envcCstj�tj�|jd��S)Nzenv.py)rrr r%r)rrrr�env_py_location�szScriptDirectory.env_py_locationcKs*tjdtj�|�tj|||jf|�dS)Nz
Generating %s)r�statusrrr Ztemplate_to_filer)r�srcra�kwrrr�_generate_template�sz"ScriptDirectory._generate_templatecCs"t�dtj�|�tj||�dS)Nz
Generating %s)rrgrrr �shutil�copy)rrhrarrr�
_copy_file�szScriptDirectory._copy_filecCs0tj�|�}tj�|�s,t�d|tj|�dS)NzCreating directory %s)rrr r&rrg�makedirs)rrrrr�_ensure_directory�s
z!ScriptDirectory._ensure_directoryc	
s$|dkrd}�jdd���j�|�}
WdQRXtt|
��t|
�krNt�d��tj��}|dkr�t�j	�dkr�x6|
D]}|dk	rtt
j�|j�}PqtWt�d��n�j
}t
j�t
j�|��}x.�j	D]}
t
j�|
�|kr�Pq�Wt�d|���jr���|���||||�}|�sBx0|
D](}|dk	�r|j�st�d	|j���qW|�r~����(d
d��fdd�t�|�D�D�}WdQRX�jt
j��jd
�|ft|�t�tdd�|
D���t�|�t�|�|tj|dk	�r�|ndd�|	��t��|�}|�r|j �st�d|j||jf���j�!|�|S)aGenerate a new revision file.

        This runs the ``script.py.mako`` template, given
        template arguments, and creates a new file.

        :param revid: String revision id.  Typically this
         comes from ``alembic.util.rev_id()``.
        :param message: the revision message, the one passed
         by the -m argument to the ``revision`` command.
        :param head: the head revision to generate against.  Defaults
         to the current "head" if no branches are present, else raises
         an exception.

         .. versionadded:: 0.7.0

        :param splice: if True, allow the "head" version to not be an
         actual head; otherwise, the selected head must be a head
         (e.g. endpoint) revision.
        :param refresh: deprecated.

        NrGz{Multiple heads are present; please specify the head revision on which the new revision should be based, or perform a merge.)r@z"Duplicate head revisions specifiedrzAMultiple version locations present, please specify --version-pathz7Path %s is not represented in current version locationszeRevision %s is not a head revision; please specify --splice to create a new branch from this revisioncSs$g|]\}}||jkr|n|j�qSr)�
branch_labelsr)r"rH�deprrrr$�sz5ScriptDirectory.generate_revision.<locals>.<listcomp>csg|]}�j�|�|f�qSr)rrL)r"rq)rrrr$�szscript.py.makocss |]}|dk	r|jndVqdS)N)r)r"�hrrr�	<genexpr>sz4ScriptDirectory.generate_revision.<locals>.<genexpr>z
empty message)Zup_revision�
down_revisionrp�
depends_on�create_dateZcomma�messagez�Version %s specified branch_labels %s, however the migration file %s does not have them; have you upgraded your script.py.mako to include the 'branch_labels' section?)"rDrrJrr]rr�datetime�nowrrr�dirnamer�normpathr r
ro�	_rev_path�is_headrZto_listrjr%r�strZtuple_rev_as_scalar�tuple�to_tupler<r)�
_from_pathrpZadd_revision)rZrevidrwrGZrefreshZsplicerpZversion_pathrurir8rvZ	norm_pathZ	vers_pathrr,r)rr�generate_revision�sr







z!ScriptDirectory.generate_revisioncCs~d�t�|pd����}t|�|jkrD|d|j��dd�dd}d|j|||j|j	|j
|j|j|j
d�}tj�||�S)N�_�rrz%s.py)rH�slug�year�month�day�hour�minute�second)r%�_slug_re�findallr9rr�rsplitrr�r�r�r�r�r�rr)rr�rev_idrwrvr��filenamerrrr|szScriptDirectory._rev_path)NNNNN)rEr8)NFFNNN)#�__name__�
__module__�__qualname__�__doc__r2r�propertyrrZmemoized_propertyrr�classmethodr5rrDrIrJrLrMrFrNrPrSrQrYrZrcrerfrjrmror�r|rrrrr	sB
%




;	
or	cs�eZdZdZ�fdd�ZdZdZedd��Zedd��Z	ed	d
��Z
dd�Zddd�Zddd�Z
dd�Zedd��Zedd��Z�ZS)r)z�Represent a single revision file in a ``versions/`` directory.

    The :class:`.Script` instance is returned by methods
    such as :meth:`.ScriptDirectory.iterate_revisions`.

    c	sN||_||_tt|�j||jtjt|dd�dd�tjt|dd�dd�d�dS)Nrpr)�defaultru)rp�dependencies)	�moduler�superr)rrtrr��getattr)rr�r�r)�	__class__rrr6s
zScript.__init__NcCst�d|j�dS)z)Return the docstring given in the script.z

r)rBr1�longdoc)rrrr�docHsz
Script.doccCs6|jj}|r.t|jd�r&|�|jj�}|��SdSdS)z)Return the docstring given in the script.�_alembic_source_encodingr�N)r�r��hasattr�decoder��strip)rr�rrrr�NszScript.longdoccCs�d|j|jrdnd|jrdnd|jr(dndf}|jrJ|d|��f7}n|d|��f7}|jrv|dt�|j�7}|jr�|d	t�|j�7}|j	r�|d
t�|j	�f7}|d|j
f7}|dd
�dd�|j�
�D��7}|S)NzRev: %s%s%s%s
z (head)r�z (branchpoint)z
 (mergepoint)zMerges: %s
zParent: %s
zAlso depends on: %s
zBranches into: %s
zBranch names: %s
z	Path: %s
z
%s
�
css|]}d|VqdS)z    %sNr)r"Zpararrrrswsz#Script.log_entry.<locals>.<genexpr>)rr}�is_branch_point�is_merge_point�_format_down_revisionr�rr<Znextrevrprr%r��
splitlines)r�entryrrr�	log_entryZs.zScript.log_entrycCs:d|��|j|jrdnd|jr"dnd|jr.dnd|jfS)Nz%s -> %s%s%s%s, %sz (head)r�z (branchpoint)z
 (mergepoint))r�rr}r�r�r�)rrrr�__str__}szScript.__str__FTcCs�|j}|r<|jr,d|��t�|j�|f}nd|��|f}|rZ|jrZ|dt�|j�7}|sb|r�|d|jrpdnd|jr�|js�dndf7}|r�|d|jr�dnd|j	r�d	ndf7}|r�|d
|j
7}|S)Nz
%s (%s) -> %sz%s -> %sz (%s)z%s%sz (head)r�z (effective head)z (branchpoint)z
 (mergepoint)z, %s)rr�r�rr<rpZ
_is_real_headr}r�r�r�)r�include_branches�include_doc�include_parents�tree_indicatorsZhead_indicators�textrrr�
_head_only�s.


zScript._head_onlycCs|r
|jS|�||||�SdS)N)r�r�)r�verboser�r�r�r�rrr�
cmd_format�s
zScript.cmd_formatcCs|js
dSt�|j�SdS)Nz<base>)rtrr<Z_versioned_down_revisions)rrrrr��szScript._format_down_revisioncCstj�|�\}}|�|||�S)N)rrr1r*)r3�	scriptdirr�dir_r�rrrr��szScript._from_pathc
Cs�|jrt�|�}n
t�|�}|s$dS|�d�}|jrR|�d�dk}|�d�dk}nd}}|sb|r�tj�tj�||��}tj�tj�||d��}	|s�|r�|	r�dSt	�
||�}
t|
d�s�t�|�}|s�t	�
d|��q�|�d�}n|
j}t|
|tj�||��S)Nrr�c�oFrz�Could not determine revision id from filename %s. Be sure the 'revision' variable is declared inside the script (please see 'Upgrading from Alembic 0.1 to 0.2' in the documentation).)r�_sourceless_rev_file�match�_only_source_rev_file�grouprrr&r%rrdr��_legacy_revrrr))
r3r�r�r�Zpy_matchZpy_filenameZis_cZis_oZ	py_existsZ
pyc_existsr��mrrrrr*�s2




zScript._from_filename)FFFTT)FFFT)r�r�r�r�rr�rr�r�r�r�r�r�r�r�r�r�r*�
__classcell__rr)r�rr)-s #

 
r))rxrrBrkr�rrrZruntimer�
contextlibr�compiler�r�r�Z_mod_def_rer�r2r0�objectr	ZRevisionr)rrrr�<module>s*







Youez - 2016 - github.com/yon3zu
LinuXploit