• File: command.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/alembic/__pycache__/command.cpython-37.pyc
  • Date Modified: 06/27/2022 11:08 PM
  • File size: 9.36 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

M!V	-	@sddlZddlmZddlmZddlmZddlmZddZ	d$d
dZ
d%ddZd&ddZd'ddZ
d(ddZddZd)ddZd*ddZd+ddZd,ddZd-d d!Zd"d#ZdS).N)ScriptDirectory)EnvironmentContext)util)autogeneratec
Cst|dxPt|D]>}ttj||d}t|}WdQRX|d||qW|d|ddS)zList available templateszAvailable templates:
ZREADMENz%s - %sz1
Templates are used via the 'init' command, e.g.:z,
  alembic init --template generic ./scripts)print_stdoutoslistdirget_template_directoryopenpathjoinnext)configZtempnameZreadmeZsynopsisr@/opt/alt/python37/lib/python3.7/site-packages/alembic/command.pylist_templates	s


rgenericc
Cs8t|tjrtd|tj||}t|tjsJtd|tdtj	|tj
|tj|d}tdtj	|tj
|t|}xt|D]~}tj||}|dkrtj	|j
}t|tjrtd|n|j|||dqtj|rtj||}	|||	qWtd|d	S)
z#Initialize a new scripts directory.zDirectory %s already existszNo such template %rzCreating directory %sversionszalembic.ini.makoz File %s already exists, skipping)Zscript_locationzNPlease edit configuration/connection/logging settings in %r before proceeding.N)raccessF_OKrCommandErrorrr
r
Zstatusabspathmakedirsrr	Zconfig_file_namemsgZ_generate_templateisfileZ
_copy_file)
rZ	directorytemplateZtemplate_dirrscriptZfile_Z	file_pathZconfig_fileZoutput_filerrrinits:



rFheadc
st|}
t|||||||||	d	}t||
|t|d}|rfd}|rXtdfdd}
n |rxfdd}
n|rtd|rt	||
|
|j
d	|
Wd
QRXddD}t
|d
kr|dS|Sd
S)zCreate a new revision file.)	messagersqlrsplicebranch_labelversion_pathrev_id
depends_onZrevision_environmentTz7Using --sql with --autogenerate does not make any sensecs||gS)N)Zrun_autogenerate)revcontext)revision_contextrrretrieve_migrations`sz%revision.<locals>.retrieve_migrationscs||gS)N)Zrun_no_autogenerate)r'r()r)rrr*dsziUsing --sql with the revision command when revision_environment is not configured does not make any sense)fnas_sql
template_argsr)NcSsg|]}|qSrr).0rrrr
<listcomp>xszrevision.<locals>.<listcomp>rr)rfrom_configdictautogenZRevisionContextrZasboolZget_main_optionrrr-run_envZgenerate_scriptslen)rr rr!rr"r#r$r%r&Zscript_directoryZcommand_argsZenvironmentr*Zscriptsr)r)rrevisionDsF


r5cCs6t|}d|i}|j|p t|fd||d|S)zMerge two revisions together.  Creates a new migration file.

    .. versionadded:: 0.7.0

    .. seealso::

        :ref:`branches`

    rT)ZrefreshrZ
branch_labels)rr0Zgenerate_revisionrr%)rZ	revisionsr r#r%rr-rrrmerges
r6c	spt|d}dkr4|s$tddd\}fdd}t|||||dWdQRXdS)zUpgrade to a later version.N:zRange revision not allowedcs|S)N)Z
_upgrade_revs)r'r()r5rrrupgradeszupgrade.<locals>.upgrade)r+r,starting_revdestination_revtag)rr0rrsplitrr3)rr5r!r<r:r9r)r5rrr9s 


r9c	st|d}dkr6|s$tddd\}n|rDtdfdd}t|||||dWdQRXdS)	zRevert to a previous version.Nr7zRange revision not allowedr8z/downgrade with --sql requires <fromrev>:<torev>cs|S)N)Z_downgrade_revs)r'r()r5rrr	downgradeszdowngrade.<locals>.downgrade)r+r,r:r;r<)rr0rrr=rr3)rr5r!r<r:r>r)r5rrr>s&


r>c	sht|dkrDfdd}t|dWdQRXn x|D]}|jqPWdS)z1Show the revision(s) denoted by the given symbol.currentcs$x|D]}|jqWgS)N)
get_revisionsr	log_entry)r'r(sc)rrrrshow_currentszshow.<locals>.show_current)r+N)rr0rr3r@rrA)rr'rCrBr)rrrshows

rDcst|}|dk	r8d|kr$td|d\}}nd}}fdddfdd	}|dkrr||||d	n&|dkr||||d
n||||dS)z.List changeset scripts in chronological order.Nr7z9History range requires [start]:[end], [start]:, or :[end]c	s<x6|j|pd|pddD]}||jddddqWdS)Nbaseheads)rErT)verboseinclude_branchesinclude_docZinclude_parents)walk_revisionsr
cmd_format)rrrErrB)rGrr_display_historysz!history.<locals>._display_historyc	s:fdd}t|dWdQRXdS)Ncs2dkr|ndkr.|gS)Nr)r'r()rLrErrrrr_display_current_historys
zMhistory.<locals>._display_history_w_current.<locals>._display_current_history)r+)rr3)rrrErrM)rL)rErrrr_display_history_w_currents
z+history.<locals>._display_history_w_currentr?)r)rE)NN)rr0rrstripr=)rZ	rev_rangerGrrErrNr)rLrGrhistorys
	rPcCsPt|}|r|d}n||}x"|D]}||j|dddq.WdS)z4Show current available heads in the script directoryrFTF)rHZtree_indicatorsN)rr0r@Z	get_headsrrK)rrGZresolve_dependenciesrrFr'rrrrFs

rFcsdt|xTD]Hjr|djdddfddfddjDDqWdS)	zShow current branch pointsz%s
%s
T)rH
c3s4|],}ddttj|jdddfVqdS)z%s -> %s FT)rHrIN)r4strr5rK)r.Zrev_obj)rBrGrr	<genexpr>'szbranches.<locals>.<genexpr>c3s|]}|VqdS)N)Zget_revision)r.r')rrrrT,sN)rr0rJZis_branch_pointrrKr
Znextrev)rrGr)rBrrGrbranchess
rUc	sNt|rtdfdd}t|dWdQRXdS)z,Display the current revision for a database.z--head-only is deprecatedcsDrdt|jjjx"|D]}|q(WgS)NzCurrent revision(s) for %s:)rrZobfuscate_url_pwZ
connectionZengineZurlr@rK)r'r()rrrGrrdisplay_version9sz current.<locals>.display_version)r+N)rr0rwarnrr3)rrGZ	head_onlyrVr)rrrGrr?1s



r?c	spt|d}dkr4|s$tddd\}fdd}t|||||dWdQRXdS)zQ'stamp' the revision table with the given revision; don't
    run any migrations.Nr7zRange revision not allowedr8cs|S)N)Z_stamp_revs)r'r()r5rrrdo_stampWszstamp.<locals>.do_stamp)r+r,r;r:r<)rr0rrr=rr3)rr5r!r<r:rXr)r5rrstampKs 


rYc	s|t||dkrBfdd}t||dWdQRXn6|}|s^td|x|D]}t|jqdWdS)z%Edit revision script(s) using $EDITORr?cs2|stdx|D]}t|jqWgS)NzNo current revisions)rrr@editr)r'r(rB)rrredit_currentls

zedit.<locals>.edit_current)r+Nz*No revision files indicated by symbol '%s')	rr0rr3r@rrrZr)rr'r[ZrevsrBr)rrrZfs




rZ)r)	NFFrFNNNN)NNN)FN)FN)NF)FF)F)FF)FN)rrrZruntime.environmentrrrr2rrr5r6r9r>rDrPrFrUr?rYrZrrrr<module>s&
,
:



-