<s> from django . core . management . base import NoArgsCommand , CommandError <EOL> from django . core . management . color import no_style <EOL> from django . utils . importlib import import_module <EOL> from optparse import make_option <EOL> class Command ( NoArgsCommand ) : <EOL> option_list = NoArgsCommand . option_list + ( <EOL> make_option ( '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , default = True , <EOL> help = '<STR_LIT>' ) , <EOL> ) <EOL> help = "<STR_LIT>" <EOL> def handle_noargs ( self , ** options ) : <EOL> from django . conf import settings <EOL> from django . db import connection , transaction , models <EOL> from django . core . management . sql import sql_flush , emit_post_sync_signal <EOL> verbosity = int ( options . get ( '<STR_LIT>' , <NUM_LIT:1> ) ) <EOL> interactive = options . get ( '<STR_LIT>' ) <EOL> self . style = no_style ( ) <EOL> for app_name in settings . INSTALLED_APPS : <EOL> try : <EOL> import_module ( '<STR_LIT>' , app_name ) <EOL> except ImportError : <EOL> pass <EOL> sql_list = sql_flush ( self . style , only_django = True ) <EOL> if interactive : <EOL> confirm = raw_input ( """<STR_LIT>""" % settings . DATABASE_NAME ) <EOL> else : <EOL> confirm = '<STR_LIT:yes>' <EOL> if confirm == '<STR_LIT:yes>' : <EOL> try : <EOL> cursor = connection . cursor ( ) <EOL> for sql in sql_list : <EOL> cursor . execute ( sql ) <EOL> except Exception , e : <EOL> transaction . rollback_unless_managed ( ) <EOL> raise CommandError ( """<STR_LIT>""" % ( settings . DATABASE_NAME , e ) ) <EOL> transaction . commit_unless_managed ( ) <EOL> emit_post_sync_signal ( models . get_models ( ) , verbosity , interactive ) <EOL> from django . core . management import call_command <EOL> call_command ( '<STR_LIT>' , '<STR_LIT>' , ** options ) <EOL> else : <EOL> print "<STR_LIT>" </s>
