%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/alembic/script/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyo

�
�M!Vc@sddlZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZejd	�Z
ejd
�Zejd�Zejd�Zejd
�ZdZejd�Zdefd��YZdejfd��YZdS(i����Ni(tutil(tcompati(trevision(t	migration(tcontextmanagers(?!__init__)(.*\.py)(c|o)?$s(?!__init__)(.*\.py)$s([a-f0-9]+)\.py$s(upgrade|downgrade)_([a-z0-9]+)s\w+s%(rev)s_%(slug)ss,|(?: +)tScriptDirectorycBsFeZdZeddedd�Zed��Ze	j
d��Zd�Ze
d��Zedddddd��Zd	d
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed��Zd�Zd�Z d�Z!deedddd�Z"d�Z#RS(sHProvides 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()



    i(sutf-8cCs�||_||_||_|p$d|_||_||_tj|j�|_	t
j|t
j�s|t
jd|��ndS(Ni(sVPath doesn't exist: %r.  Please use the 'init' command to create a new scripts folder.(tdirt
file_templatetversion_locationsttruncate_slug_lengtht
sourcelesstoutput_encodingRtRevisionMapt_load_revisionstrevision_maptostaccesstF_OKRtCommandError(tselfRRR	RR
R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt__init__*s						cCs9|j}t|�dkr-tjd��n|dSdS(Nis"Multiple version_locations presenti(t_version_locationstlenRR(Rtloc((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytversions;s	cCsa|jr8g|jD]!}tjjtj|��^qStjjtjj|jd��fSdS(NR(RRtpathtabspathRtcoerce_resource_to_filenametjoinR(Rtlocation((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRCs	,ccs�|jr:g|jD]}tjj|�r|^q}n|jg}xT|D]L}xCtj|�D]2}tj|||�}|dkr�qcn|VqcWqMWdS(N(
RRRRtexistsRtlistdirtScriptt_from_filenametNone(Rtverstpathstfile_tscript((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR
Ms	!
cCs�|jd�}|d
kr-tjd��n|jd�}|d
k	rWt|�}n|jd�}|r~tj|�}nttj|�d|jdt	�d|d|jd�dkd|jdd	�d|�S(s�Produce a new :class:`.ScriptDirectory` given a :class:`.Config`
        instance.

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

        tscript_locations0No 'script_location' key found in configuration.R	RRR
ttrueRsutf-8N(
tget_main_optionR"RRtintt_split_on_space_commatsplitRRt_default_file_template(tclstconfigR'R	R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytfrom_config\s$		c
cssy	dVWnctjk
r�}|dkr6|j}n|dkrN|j}n|s]d}n|i|d6|d6}tjtj|��n�tj	k
r�}|s�d}n|i|p�|j
d6tj|j�d6}tjtj|��nztj
k
r<}|dkr#d|j
}ntjtj|��n3tjk
rn}	tjtj|	jd��nXdS(	NsgRequested range %(start)s:%(end)s does not refer to ancestor/descendant revisions along the same branchtstarttends�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 headsthead_argtheadss(Can't locate revision identified by '%s'i(RtRangeNotAncestorErrorR"tlowertupperRtraise_from_causeRRt
MultipleHeadstargumenttformat_as_commaR4tResolutionErrort
RevisionErrortargs(
Rtancestortmultiple_headsR1R2t
resolutiontrnatmhtreterr((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt_catch_revision_errors{s2			
tbaseR4ccsT|jd|d|��6x.|jj||dtdt�D]}|Vq;WWdQXdS(s�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.

        R1R2t	inclusivetassert_relative_lengthN(RFRtiterate_revisionstTruetFalse(RRGtheadtrev((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytwalk_revisions�scCs'|j��|jj|�SWdQXdS(s�Return the :class:`.Script` instance with the given rev identifier,
        symbolic name, or sequence of identifiers.

        .. versionadded:: 0.7.0

        N(RFRt
get_revisions(Rtid_((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRP�s
cCs'|j��|jj|�SWdQXdS(s�Return the :class:`.Script` instance with the given rev id.

        .. seealso::

            :meth:`.ScriptDirectory.get_revisions`

        N(RFRtget_revision(RRQ((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRR�s	
cCsA|j��|jj|�\}}WdQX|s5dS|dSdS(s[Convert a symbolic revision, i.e. 'head' or 'base', into
        an actual revision number.Ni(RFRt_resolve_revision_numberR"(RRQRNtbranch_name((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytas_revision_number�s

cCs|jj||�S(s�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`

        (RRJ(RR7R6((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRJ�scCs*|jdd��|jj�SWdQXdS(sGReturn 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`

        R@s}The script directory has multiple heads (due to branching).Please use get_heads(), or merge the branches using alembic merge.N(RFRtget_current_head(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRV�s	
cCst|jj�S(sUReturn 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.
        (tlistRR4(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt	get_headsscCsF|j�}t|�dkr0tjd��n|r>|dSdSdS(s#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.

        is@The script directory has multiple bases. Please use get_bases().iN(t	get_basesRRRR"(Rtbases((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytget_basescCst|jj�S(s�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

        (RWRRZ(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRY%s	c	Cs|jddd|��a|jj||dt�}t|�}gtt|��D]}tjj|j|�^qSSWdQXdS(NR?sFDestination %(end)s is not a valid upgrade target from current head(s)R2t
implicit_base(	RFRRJRKRWtreversedRt
MigrationSteptupgrade_from_script(Rtdestinationtcurrent_revtrevsR&((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt
_upgrade_revs0s	
	c	Csa|jddd|��C|jj||�}g|D]}tjj|j|�^q5SWdQXdS(NR?sHDestination %(end)s is not a valid downgrade target from current head(s)R2(RFRRJRR^tdowngrade_from_script(RR`RaRbR&((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt_downgrade_revs=s	
	cCs�|jdd���|j|�}|jj||dt�}g}|j|�pXdg}xz|D]r}|dkr�|jg|D]!}tj|j	dt
t�^q��qbn||kr�qbnt|jj|g��}t|jj
|g��}	|j|�rPg|D]}|j	^q
}
tj|
|j	t
t
�}|j|�qbqb|	j|�r�g|D]}|j	^qf}
tj|
|j	tt
�}|j|�qbqbtjd|j	tt�}|j|�qbqbW|SWdQXdS(NR@sCMultiple heads are present; please specify a single target revisiontinclude_dependencies((RFRPRtfilter_for_lineageRKR"textendRt	StampStepRRLtsett_get_descendant_nodest_get_ancestor_nodestintersectiontappend(RRR4tfiltered_headststepstdeststdestRMtdescendantst	ancestorst
todo_headststep((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt_stamp_revsIsD	
	
,


cCstj|jd�dS(s�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`.


        senv.pyN(Rtload_python_fileR(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytrun_env�s	cCs"tjjtjj|jd��S(Nsenv.py(RRRRR(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytenv_py_location�scKs6tjdtjj|�tj|||j|�dS(Ns
Generating %s(RtstatusRRRttemplate_to_fileR(RtsrcRrtkw((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt_generate_template�scCs-tjdtjj|�tj||�dS(Ns
Generating %s(RR{RRRtshutiltcopy(RR}Rr((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt
_copy_file�scCsEtjj|�}tjj|�sAtjd|tj|�ndS(NsCreating directory %s(RRRRRR{tmakedirs(RR((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt_ensure_directory�s
c	Ks@|dkrd}n|jdd��|jj|�}
WdQXtt|
��t|
�krptjd��ntjj	�}|dkr�t|j
�dkr�xN|
D]+}|dk	r�tjj
|j�}Pq�q�Wtjd��q�|j}ntjjtjj|��}x@|j
D]"}
tjj|
�|krPqqWtjd|��|jrn|j|�n|j||||�}|s�x@|
D]5}|dk	r�|jr�tjd	|j��q�q�Wn|rP|j��jggtj|�D]}|jj|�|f^q�D]*\}}||jkr8|n|j^q}WdQXn|jtjj|jd
�|dt|�dtjtd
�|
D���dtj|�dtj|�d|dtj d|dk	r�|nd|	�t!j"||�}|r,|jr,tjd|j||jf��n|jj#|�|S(sGenerate 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.

        RMR@s{Multiple heads are present; please specify the head revision on which the new revision should be based, or perform a merge.Ns"Duplicate head revisions specifiedisAMultiple version locations present, please specify --version-paths7Path %s is not represented in current version locationsseRevision %s is not a head revision; please specify --splice to create a new branch from this revisionsscript.py.makotup_revisiont
down_revisioncss*|] }|dk	r|jndVqdS(N(R"R(t.0th((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pys	<genexpr>st
branch_labelst
depends_ontcreate_datetcommatmessages
empty messages�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?($R"RFRRPRRjRRtdatetimetnowRRRtdirnameRtnormpathRRR�t	_rev_pathtis_headRtto_listRRR�RRRtstrttuple_rev_as_scalarttupletto_tupleR;R t
_from_pathtadd_revision(RtrevidR�RMtrefreshtspliceR�tversion_pathR�R~R4R�t	norm_patht	vers_pathRtdepRNR&((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytgenerate_revision�sr		


	

h	cCs�djtj|pd��j�}t|�|jkr]||j jdd�dd}nd|ji|d6|d6|jd6|j	d	6|j
d
6|jd6|jd6|j
d
6}tjj||�S(Nt_tiis%s.pyRNtslugtyeartmonthtdaythourtminutetsecond(Rt_slug_retfindallR6RR	trsplitRR�R�R�R�R�R�RR(RRtrev_idR�R�R�tfilename((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR�s$$	




N($t__name__t
__module__t__doc__R-R"RLRtpropertyRRtmemoized_propertyRR
tclassmethodR0RRFRORPRRRURJRVRXR[RYRcReRwRyRzRR�R�R�R�(((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRsB
	%	
		
			
			
		;						oR cBs�eZdZd�ZdZdZed��Zed��Z	ed��Z
d�Zeeee
e
d�Zeeee
d�Zd�Zed	��Zed
��ZRS(s�Represent a single revision file in a ``versions/`` directory.

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

    cCst||_||_tt|�j||jdtjt|dd�dd�dtjt|dd�dd��dS(NR�tdefaulttdependenciesR�(((
tmoduleRtsuperR RR�RR�tgetattrR"(RR�R�R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR6s			cCstjd|j�dS(s)Return the docstring given in the script.s

i(RDR,tlongdoc(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytdocHscCsN|jj}|rFt|jd�r<|j|jj�}n|j�SdSdS(s)Return the docstring given in the script.t_alembic_source_encodingR�N(R�R�thasattrtdecodeR�tstrip(RR�((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR�Ns
cCs7d|j|jrdnd|jr*dnd|jr<dndf}|jri|d|j�f7}n|d|j�f7}|jr�|dtj|j�7}n|jr�|d	tj|j�7}n|j	r�|d
tj|j	�f7}n|d|j
f7}|dd
jd�|jj
�D��7}|S(NsRev: %s%s%s%s
s (head)R�s (branchpoint)s
 (mergepoint)sMerges: %s
sParent: %s
sAlso depends on: %s
sBranches into: %s
sBranch names: %s
s	Path: %s
s
%s
s
css|]}d|VqdS(s    %sN((R�tpara((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pys	<genexpr>ws(RR�tis_branch_pointtis_merge_pointt_format_down_revisionR�RR;tnextrevR�RRR�t
splitlines(Rtentry((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt	log_entryZs.				cCsSd|j�|j|jr!dnd|jr3dnd|jrEdnd|jfS(Ns%s -> %s%s%s%s, %ss (head)R�s (branchpoint)s
 (mergepoint)(R�RR�R�R�R�(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt__str__}s	cCs)|j}|rY|jr@d|j�tj|j�|f}qYd|j�|f}n|r�|jr�|dtj|j�7}n|s�|r�|d|jr�dnd|jr�|jr�dndf7}n|r|d|jr�dnd|j	r�d	ndf7}n|r%|d
|j
7}n|S(Ns
%s (%s) -> %ss%s -> %ss (%s)s%s%ss (head)R�s (effective head)s (branchpoint)s
 (mergepoint)s, %s(RR�R�RR;R�t
_is_real_headR�R�R�R�(Rtinclude_branchestinclude_doctinclude_parentsttree_indicatorsthead_indicatorsttext((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt
_head_only�s.			
	cCs'|r
|jS|j||||�SdS(N(R�R�(RtverboseR�R�R�R�((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt
cmd_format�s
cCs!|js
dStj|j�SdS(Ns<base>(R�RR;t_versioned_down_revisions(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR��s	cCs+tjj|�\}}|j|||�S(N(RRR,R!(R.t	scriptdirRtdir_R�((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR��sc
	Cst|jrtj|�}ntj|�}|s4dS|jd�}|jry|jd�dk}|jd�dk}n
t}}|s�|r�tjj	tjj
||��}tjj	tjj
||d��}	|s�|r�|	r�dSntj||�}
t
|
d�sLtj|�}|s:tjd|��qU|jd�}n	|
j}t|
|tjj
||��S(NiitctoRs�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
t_sourceless_rev_filetmatcht_only_source_rev_fileR"tgroupRLRRRRRRxR�t_legacy_revRRR (
R.R�R�R�tpy_matchtpy_filenametis_ctis_ot	py_existst
pyc_existsR�tmR((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR!�s2		
!%
	N(R�R�R�RR"R�RR�R�R�R�R�RLRKR�R�R�R�R�R!(((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR -s 	#	
 	(R�RRDR�R�RRRtruntimeRt
contextlibRtcompileR�R�R�t_mod_def_reR�R-R+tobjectRtRevisionR (((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt<module>s&��

Zerion Mini Shell 1.0