config.print_stdout("Available templates:\n")
for tempname in os.listdir(config.get_template_directory()):
- readme = os.path.join(
+ with open(os.path.join(
config.get_template_directory(),
tempname,
- 'README')
- synopsis = open(readme).next()
+ 'README')) as readme:
+ synopsis = readme.next()
config.print_stdout("%s - %s", tempname, synopsis)
config.print_stdout("\nTemplates are used via the 'init' command, e.g.:")
logger.info("Migrating database %s" % name)
file_ = "%s.sql" % name
logger.info("Writing output to %s" % file_)
- context.configure(
- url=rec['url'],
- output_buffer=open(file_, 'w')
- )
- with context.begin_transaction():
- context.run_migrations(engine_name=name)
+ with open(file_, 'w') as buffer:
+ context.configure(url=rec['url'], output_buffer=buffer)
+ with context.begin_transaction():
+ context.run_migrations(engine_name=name)
def run_migrations_online():
"""Run migrations in 'online' mode.