<s> from orator . migrations import Migrator , DatabaseMigrationRepository <EOL> from . base_command import BaseCommand <EOL> class StatusCommand ( BaseCommand ) : <EOL> """<STR_LIT>""" <EOL> def handle ( self ) : <EOL> """<STR_LIT>""" <EOL> database = self . option ( '<STR_LIT>' ) <EOL> self . resolver . set_default_connection ( database ) <EOL> repository = DatabaseMigrationRepository ( self . resolver , '<STR_LIT>' ) <EOL> migrator = Migrator ( repository , self . resolver ) <EOL> if not migrator . repository_exists ( ) : <EOL> return self . error ( '<STR_LIT>' ) <EOL> self . _prepare_database ( migrator , database ) <EOL> path = self . option ( '<STR_LIT:path>' ) <EOL> if path is None : <EOL> path = self . _get_migration_path ( ) <EOL> ran = migrator . get_repository ( ) . get_ran ( ) <EOL> migrations = [ ] <EOL> for migration in migrator . _get_migration_files ( path ) : <EOL> if migration in ran : <EOL> migrations . append ( [ '<STR_LIT>' % migration , '<STR_LIT>' ] ) <EOL> else : <EOL> migrations . append ( [ '<STR_LIT>' % migration , '<STR_LIT>' ] ) <EOL> if migrations : <EOL> table = self . table ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> migrations <EOL> ) <EOL> table . render ( ) <EOL> else : <EOL> return self . error ( '<STR_LIT>' ) <EOL> for note in migrator . get_notes ( ) : <EOL> self . line ( note ) <EOL> def _prepare_database ( self , migrator , database ) : <EOL> migrator . set_connection ( database ) </s>
