diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-09-09 12:24:43 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-09-09 12:24:43 -0400 |
commit | 10d3556a5501563a4110733ecc9d9ba8eb172a99 (patch) | |
tree | 0646aa84d3f89c2f9cf59ba298e06d5c1f312ee1 /alembic/command.py | |
parent | effe3d89238923c5913449879adb1c685eb17c60 (diff) | |
download | alembic-10d3556a5501563a4110733ecc9d9ba8eb172a99.tar.gz |
- do an autopep8 pass for just about everything other
than line length
Diffstat (limited to 'alembic/command.py')
-rw-r--r-- | alembic/command.py | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/alembic/command.py b/alembic/command.py index f1c5962..a6d7995 100644 --- a/alembic/command.py +++ b/alembic/command.py @@ -4,21 +4,23 @@ from .script import ScriptDirectory from .environment import EnvironmentContext from . import util, autogenerate as autogen + def list_templates(config): """List available templates""" config.print_stdout("Available templates:\n") for tempname in os.listdir(config.get_template_directory()): with open(os.path.join( - config.get_template_directory(), - tempname, - 'README')) as readme: + config.get_template_directory(), + tempname, + 'README')) as readme: synopsis = next(readme) config.print_stdout("%s - %s", tempname, synopsis) config.print_stdout("\nTemplates are used via the 'init' command, e.g.:") config.print_stdout("\n alembic init --template pylons ./scripts") + def init(config, directory, template='generic'): """Initialize a new scripts directory.""" @@ -26,7 +28,7 @@ def init(config, directory, template='generic'): raise util.CommandError("Directory %s already exists" % directory) template_dir = os.path.join(config.get_template_directory(), - template) + template) if not os.access(template_dir, os.F_OK): raise util.CommandError("No such template %r" % template) @@ -58,8 +60,9 @@ def init(config, directory, template='generic'): output_file ) - util.msg("Please edit configuration/connection/logging "\ - "settings in %r before proceeding." % config_file) + util.msg("Please edit configuration/connection/logging " + "settings in %r before proceeding." % config_file) + def revision(config, message=None, autogenerate=False, sql=False): """Create a new revision file.""" @@ -77,6 +80,7 @@ def revision(config, message=None, autogenerate=False, sql=False): if autogenerate: environment = True + def retrieve_migrations(rev, context): if script.get_revision(rev) is not script.get_revision("head"): raise util.CommandError("Target database is not up to date.") @@ -124,6 +128,7 @@ def upgrade(config, revision, sql=False, tag=None): ): script.run_env() + def downgrade(config, revision, sql=False, tag=None): """Revert to a previous version.""" @@ -150,6 +155,7 @@ def downgrade(config, revision, sql=False, tag=None): ): script.run_env() + def history(config, rev_range=None): """List changeset scripts in chronological order.""" @@ -157,16 +163,16 @@ def history(config, rev_range=None): if rev_range is not None: if ":" not in rev_range: raise util.CommandError( - "History range requires [start]:[end], " - "[start]:, or :[end]") + "History range requires [start]:[end], " + "[start]:, or :[end]") base, head = rev_range.strip().split(":") else: base = head = None def _display_history(config, script, base, head): for sc in script.walk_revisions( - base=base or "base", - head=head or "head"): + base=base or "base", + head=head or "head"): if sc.is_head: config.print_stdout("") config.print_stdout(sc.log_entry) @@ -202,14 +208,16 @@ def branches(config): config.print_stdout(sc) for rev in sc.nextrev: config.print_stdout("%s -> %s", - " " * len(str(sc.down_revision)), - script.get_revision(rev) - ) + " " * len(str(sc.down_revision)), + script.get_revision(rev) + ) + def current(config, head_only=False): """Display the current revision for each database.""" script = ScriptDirectory.from_config(config) + def display_version(rev, context): rev = script.get_revision(rev) @@ -232,11 +240,13 @@ def current(config, head_only=False): ): script.run_env() + def stamp(config, revision, sql=False, tag=None): """'stamp' the revision table with the given revision; don't run any migrations.""" script = ScriptDirectory.from_config(config) + def do_stamp(rev, context): if sql: current = False @@ -257,6 +267,7 @@ def stamp(config, revision, sql=False, tag=None): ): script.run_env() + def splice(config, parent, child): """'splice' two branches, creating a new revision file. |