def METHOD_NAME(self, filename):
    try:
        os.makedirs(os.path.split(filename)[0])
    except OSError:
        pass
    buf = []
    merged_table = self.get_merged_dict()
    keys = list(merged_table.keys())
    keys.sort()
    try:
        fun = ascii
    except NameError:
        fun = repr
    for k in keys:
        if k != 'undo_stack':
            buf.append('%s = %s\n' % (k, fun(merged_table[k])))
    Utils.writef(filename, ''.join(buf))