def write_sqlite_headers(self): "Transform sql files into header files" import transform_sql for hdrfile, sqlfile in self.graph.get_deps(DT_SQLHDR): new_hdrfile = hdrfile + ".new" new_file = open(new_hdrfile, 'w') transform_sql.main(sqlfile[0], new_file) new_file.close() def identical(file1, file2): try: if filecmp.cmp(new_hdrfile, hdrfile): return True else: return False except: return False if identical(new_hdrfile, hdrfile): os.remove(new_hdrfile) else: try: os.remove(hdrfile) except: pass os.rename(new_hdrfile, hdrfile)