<s> from optparse import make_option <EOL> from django . conf import settings <EOL> from django . core . management . base import AppCommand , CommandError <EOL> from django . core . management . color import no_style <EOL> from django . core . management . sql import sql_reset <EOL> from django . db import connections , transaction , DEFAULT_DB_ALIAS <EOL> class Command ( AppCommand ) : <EOL> option_list = AppCommand . option_list + ( <EOL> make_option ( '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , default = True , <EOL> help = '<STR_LIT>' ) , <EOL> make_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , <EOL> default = DEFAULT_DB_ALIAS , help = '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ) <EOL> help = "<STR_LIT>" <EOL> args = '<STR_LIT>' <EOL> output_transaction = True <EOL> def handle_app ( self , app , ** options ) : <EOL> import warnings <EOL> warnings . warn ( <EOL> '<STR_LIT>' , <EOL> PendingDeprecationWarning <EOL> ) <EOL> using = options . get ( '<STR_LIT>' , DEFAULT_DB_ALIAS ) <EOL> connection = connections [ using ] <EOL> app_name = app . __name__ . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:2> ] <EOL> self . style = no_style ( ) <EOL> sql_list = sql_reset ( app , self . style , connection ) <EOL> if options . get ( '<STR_LIT>' ) : <EOL> confirm = raw_input ( """<STR_LIT>""" % ( app_name , connection . settings_dict [ '<STR_LIT>' ] ) ) <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>""" % ( app_name , app_name , e ) ) <EOL> transaction . commit_unless_managed ( ) <EOL> else : <EOL> print "<STR_LIT>" </s>
