ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ M!Vc@sddlZddlZddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ej d Z ej d Zej d Zej d Zej d ZdZej dZdefdYZdejfdYZdS(iNi(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,|(?: +)tScriptDirectorycBsFeZdZeddeddZedZe j dZ dZ e dZeddddddZd d d Zd Zd ZdZdZdZdZdZdZdZdZdZdZedZdZdZ dZ!deeddddZ"dZ#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_encodingRt RevisionMapt_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-tjdn|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|jdfSdS(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|||}|dkrqcn|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-tjdn|jd}|d k rWt|}n|jd}|r~tj|}nttj|d|jdt d|d|jddkd|jdd d|S( sProduce 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 ttrueR sutf-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.pyt from_config\s$    c cssy dVWnctjk r}|dkr6|j}n|dkrN|j}n|s]d}n|i|d6|d6}tjtj|ntj k r}|sd}n|i|p|j d6tj |j d6}tjtj|nztj k r<}|dkr#d|j }ntjtj|n3tjk rn} tjtj| jdnXdS( NsgRequested range %(start)s:%(end)s does not refer to ancestor/descendant revisions along the same branchtstarttendsMultiple head revisions are present for given argument '%(head_arg)s'; please specify a specific target revision, '@%(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         tbaseR4c csT|jd|d|6x.|jj||dtdtD] }|Vq;WWdQXdS(sIterate 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_revisionss cCs'|j|jj|SWdQXdS(sReturn 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.pyRPs cCs'|j|jj|SWdQXdS(sReturn 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.pyRRs 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"(RRQRNt branch_name((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytas_revision_numbers  cCs|jj||S(sIterate 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.pyRJscCs*|jdd|jjSWdQXdS(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.pyRVs  cCst|jjS(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_headss cCsF|j}t|dkr0tjdn|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|jjS(sreturn 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(Rt destinationt current_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}x|D]}|dkr|jg|D]!}tj|j dt t^qqbn||krqbnt |jj |g}t |jj |g} |j|rf| j| stg|D]}|j ^q#} tj| |j t t } |j| qbqb| j|rg|D]}|j ^q|} 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 intersectiontAssertionErrortappend( RRR4tfiltered_headststepstdeststdestRMt descendantst ancestorst todo_headststep((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt _stamp_revsIsF     ,    cCstj|jddS(sRun 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_envs cCs"tjjtjj|jdS(Nsenv.py(RRRRR(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytenv_py_locationscKs6tjdtjj|tj|||j|dS(Ns Generating %s(RtstatusRRRttemplate_to_fileR (RtsrcRstkw((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt_generate_templates cCs-tjdtjj|tj||dS(Ns Generating %s(RR|RRRtshutiltcopy(RR~Rs((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt _copy_filescCsEtjj|}tjj|sAtjd|tj|ndS(NsCreating directory %s(RRRRRR|tmakedirs(RR((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt_ensure_directorys c Ks@|dkrd}n|jdd|jj|} WdQXtt| t| krptjdntjj } |dkrt|j dkrxN| D]+}|dk rt j j |j }PqqWtjdq|j}nt j jt j j|} x@|j D]"} t j j| | krPqqWtjd||jrn|j|n|j|||| }|sx@| D]5}|dk r|j rtjd |jqqWn|rP|jjggtj|D]}|jj||f^qD]*\}}||jkr8|n|j^q}WdQXn|jt j j|jd |d t|d tjtd | Ddtj|dtj|d| dtj d|dk r|nd| t!j"||}|r,|j r,tjd|j||j fn|jj#||S(s Generate 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.makot up_revisiont down_revisioncss*|] }|dk r|jndVqdS(N(R"R(t.0th((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pys st branch_labelst depends_ont create_datetcommatmessages empty messagesVersion %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"RFRRPRRjRRtdatetimetnowRRRtdirnameRtnormpathRRRt _rev_pathtis_headRtto_listRRRRRRtstrttuple_rev_as_scalarttupletto_tupleR;R t _from_patht add_revision(RtrevidRRMtrefreshtspliceRt version_pathRRR4Rt norm_patht vers_pathRtdepRNR&((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pytgenerate_revisionsr             h  cCsdjtj|pdj}t||jkr]||j jdddd}nd|ji|d6|d6|jd6|j d 6|j d 6|j d 6|j d 6|j d 6}tjj||S(Nt_tiis%s.pyRNtslugtyeartmonthtdaythourtminutetsecond(Rt_slug_retfindallR6RR trsplitRRRRRRRRR(RRtrev_idRRRtfilename((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRs$$      N($t__name__t __module__t__doc__R-R"RLRtpropertyRRtmemoized_propertyRR t classmethodR0RRFRORPRRRURJRVRXR[RYRcReRxRzR{RRRRR(((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRsB  %    ;    oR cBseZdZdZd Zd ZedZedZ edZ dZ e e e e e dZe e e e dZdZed Zed ZRS( sRepresent a single revision file in a ``versions/`` directory. The :class:`.Script` instance is returned by methods such as :meth:`.ScriptDirectory.iterate_revisions`. c Cst||_||_tt|j||jdtjt|dddddtjt|dddddS(NRtdefaultt dependenciesR((( tmoduleRtsuperR RRRRtgetattrR"(RRRR((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR6s   cCstjd|jdS(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|jdr<|j|jj}n|jSdSdS(s)Return the docstring given in the script.t_alembic_source_encodingRN(RRthasattrtdecodeRtstrip(RR((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRNs   cCs7d|j|jrdnd|jr*dnd|jr<dndf}|jri|d|jf7}n|d|jf7}|jr|dtj|j7}n|jr|d tj|j7}n|j r|d tj|j f7}n|d |j f7}|d d j d|j j D7}|S(NsRev: %s%s%s%s s (head)Rs (branchpoint)s (mergepoint)s Merges: %s s Parent: %s sAlso depends on: %s sBranches into: %s sBranch names: %s s Path: %s s %s s css|]}d|VqdS(s %sN((Rtpara((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pys ws(RRtis_branch_pointtis_merge_pointt_format_down_revisionRRR;tnextrevRRRRt 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)Rs (branchpoint)s (mergepoint)(RRRRRR(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt__str__}s cCs)|j}|rY|jr@d|jtj|j|f}qYd|j|f}n|r|jr|dtj|j7}n|s|r|d|jrdnd|jr|j rdndf7}n|r |d|jrdnd|j rd ndf7}n|r%|d |j 7}n|S( Ns %s (%s) -> %ss%s -> %ss (%s)s%s%ss (head)Rs (effective head)s (branchpoint)s (mergepoint)s, %s( RRRRR;Rt _is_real_headRRRR(Rtinclude_branchest include_doctinclude_parentsttree_indicatorsthead_indicatorsttext((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt _head_onlys.      cCs'|r |jS|j||||SdS(N(RR(RtverboseRRRR((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyt cmd_formats cCs!|js dStj|jSdS(Ns(RRR;t_versioned_down_revisions(R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRs cCs+tjj|\}}|j|||S(N(RRR,R!(R.t scriptdirRtdir_R((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyRsc Cst|jrtj|}ntj|}|s4dS|jd}|jry|jddk}|jddk}n t}}|s|rtjj tjj ||}tjj tjj ||d} |s|r| rdSnt j ||} t | dsLtj|} | s:t jd|qU| jd} n | j} t| | tjj ||S(NiitctoRsCould 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"tgroupRLRRRRRRyRt _legacy_revRRR ( R.RRRtpy_matcht py_filenametis_ctis_ot py_existst pyc_existsRtmR((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR!s2    !%  N(RRRRR"RRRRRRRRLRKRRRRRR!(((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyR -s   #   (RRRDRRRRRtruntimeRt contextlibRtcompileRRRt _mod_def_reRR-R+tobjectRtRevisionR (((sD/opt/alt/python27/lib/python2.7/site-packages/alembic/script/base.pyts&