<commit_before># -*- coding: utf-8 -*-
import sqlalchemy
class DbDiff(object):
    def __init__(self, model, database_engine, excludedTables=None):
        #get metadata from model and database
        self.database = sqlalchemy.MetaData(database_engine, reflect = True)
        #import pdb; pdb.set_trace()
        self.conn = self.database._bind
        self.model = model
        #construct sets of all tables in database/model
        self.tablesInModel = set(self.model.tables.keys())
        self.tablesInDatabase = set(self.database.tables.keys())
        self.exclude = set(excludedTables or [])
        #construct sets with tablenames of missing and extra tables in database and model
        self.tables_missing_in_model = self.tables_extra_in_database = set(\
            sorted(self.tablesInDatabase - self.tablesInModel - self.exclude))
        self.tables_missing_in_database = self.tables_extra_in_model = set(\
            sorted(self.tablesInModel - self.tablesInDatabase - self.exclude))
        
        self.tables_different = {}
        for table_name in self.tablesInDatabase ^ self.tables_missing_in_database:
            self.diff_table = TableDiff(self.model.tables[table_name],
                                        self.database.tables[table_name],
                                        table_name)
            if self.diff_table:
                self.tables_different[table_name] = self.diff_table
        
        self.differences = bool(self.tables_missing_in_database or self.tables_extra_in_database or
                                self.tables_different)
        
    def __nonzero__(self):
        return self.differences
    __bool__ = __nonzero__
    
    def tables_to_operate(self):<commit_msg>does not crash anymore if there are unused modules<commit_after># -*- coding: utf-8 -*-
import sqlalchemy
class DbDiff(object):
    def __init__(self, model, database_engine, excludedTables=None):
        #get metadata from model and database
        self.database = sqlalchemy.MetaData(database_engine, reflect = True)
        #import pdb; pdb.set_trace()
        self.conn = self.database._bind
        self.model = model
        #construct sets of all tables in database/model
        self.tablesInModel = set(self.model.tables.keys())
        self.tablesInDatabase = set(self.database.tables.keys())
        self.exclude = set(excludedTables or [])
        #construct sets with tablenames of missing and extra tables in database and model
        self.tables_missing_in_model = self.tables_extra_in_database = set(\
            sorted(self.tablesInDatabase - self.tablesInModel - self.exclude))
        self.tables_missing_in_database = self.tables_extra_in_model = set(\
            sorted(self.tablesInModel - self.tablesInDatabase - self.exclude))
        
        self.tables_different = {}
        for table_name in self.tablesInDatabase ^ self.tables_missing_in_database:
	    try:
		self.diff_table = TableDiff(self.model.tables[table_name],
					    self.database.tables[table_name],
					    table_name)
		if self.diff_table:
		    self.tables_different[table_name] = self.diff_table
	    except KeyError:
		continue
        self.differences = bool(self.tables_missing_in_database or self.tables_extra_in_database or
                                self.tables_different)
        
    def __nonzero__(self):
        return self.differences
    __bool__ = __nonzero__
    
    def tables_to_operate(self):
{'fraction_non_alphanumeric': 0.08162083936324167, 'fraction_numerical': 0.0005788712011577424, 'mean_word_length': 2.540983606557377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2849349', 'n_tokens_mistral': 976, 'n_tokens_neox': 941, 'n_words': 203}