#NEWLINE# def reset_db( self , default_data = None ) : #NEWLINE# #INDENT# 'Remove all data from Trac tables, keeping the tables themselves.\n\n        :param default_data: after clean-up, initialize with default data\n        :return: True upon success\n        ' #NEWLINE# from trac import db_default #NEWLINE# tables = [ ] #NEWLINE# dbm = self . global_databasemanager #NEWLINE# try : #NEWLINE# #INDENT# with self . db_transaction as db : #NEWLINE# #INDENT# db . rollback ( ) #NEWLINE# db_version = dbm . get_database_version ( ) #NEWLINE# #UNINDENT# #UNINDENT# except ( TracError , self . env . db_exc . DatabaseError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_version == db_default . db_version ) : #NEWLINE# #INDENT# tables = dbm . reset_tables ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . destroy_db ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not tables ) : #NEWLINE# #INDENT# dbm . init_db ( ) #NEWLINE# if ( self . dburi != 'sqlite::memory:' ) : #NEWLINE# #INDENT# dbm . shutdown ( ) #NEWLINE# #UNINDENT# #UNINDENT# if default_data : #NEWLINE# #INDENT# dbm . insert_into_tables ( db_default . get_data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dbm . set_database_version ( db_default . db_version )