def upload_map(map_id, sheet, config_type=1): """# upload_single: docstring args: re: --- arg returns: 0 --- """ result = [] iter_r = sheet.iter_rows() for i, row in enumerate(iter_r): if i == 0: continue if row[0].internal_value is None: break r = [] for cell in row: if cell.internal_value is None: break r.append(int(cell.internal_value)) result.append(r) c = ConfigManager.get_config_obj('map', config_type=config_type) if DEBUG or c.value.get(str(map_id)) != result: data = [(k, v) for k, v in c.value.iteritems()] data.sort(key=lambda x: x[0]) m_version = make_version(data) c.value[str(map_id)] = result c.version = m_version c.save() return m_version
def upload_box_reward(box_id, sheet, config_type=1): """# upload_single: docstring args: re: --- arg returns: 0 --- """ data = xls_convert.to_pyobj(sheet) str_config = xls_convert.to_config_string('box_reward', data) dict_config = eval(str_config) c = ConfigManager.get_config_obj('box_reward_new', config_type=config_type) if DEBUG or c.value.get(box_id) != dict_config: data = [(k, sorted(v.iteritems(), key=lambda x: x[1])) for k, v in c.value.iteritems()] data.sort(key=lambda x: x[0]) m_version = make_version(data) c.value[box_id] = dict_config c.version = m_version c.save() return m_version
def upload_guide(config_name, sheet, config_type=1): """分组新手引导步骤 args: config_name: 配置名字 sheet: xlsx sheet对象 """ data = xls_convert.to_pyobj(sheet) str_config = xls_convert.to_config_string(config_name, data) dict_config = eval(str_config) result = {} for guide_id, obj in dict_config.iteritems(): id_data = result.setdefault(obj['guide_team'], {}) id_data[guide_id] = obj c = ConfigManager.get_config_obj(config_name, config_type=config_type) if DEBUG or c.value != result: m_version = make_version(str_config) c.value = result c.version = m_version c.save() return m_version
def upload_middle_map_data(map_id, sheet, config_type=1): """# upload_middle_map_data: docstring args: map_id, sheet: --- arg returns: 0 --- """ result = [] iter_r = sheet.iter_rows() for i, row in enumerate(iter_r): if i == 0: continue if row[0].internal_value is None: break r = [] for cell in row: v = cell.internal_value if v is None: break try: v = int(v) r.append(xls_convert.mapping['int_list']("""[%d, 1]""" % v)) except ValueError: r.append(xls_convert.mapping['int_list'](v)) result.append(r) c = ConfigManager.get_config_obj('middle_map_data', config_type=config_type) if DEBUG or c.value.get(str(map_id)) != result: data = [(k, v) for k, v in c.value.iteritems()] data.sort(key=lambda x: x[0]) m_version = make_version(data) c.value[str(map_id)] = result c.version = m_version c.save() return m_version
data, done_list, need_private_city_test = trans_config( filename, cv, done_list, config_type=config_type) except Exception, e: etype, value, tb = sys.exc_info() line = traceback.format_exception_only(etype, value) line_str = '-'.join(line) return 100, line_str.replace('\\', '') # -99 用于配置表内容逻辑有误时的return code if done_list == 'bug': return -99, data for config_name, sheet_title, str_config in data: c = ConfigManager.get_config_obj(config_name, config_type=config_type) if DEBUG or c.value != str_config: m_version = make_version(str_config) c.value = str_config c.version = m_version c.save() cv.update_single(config_name, hex_version=m_version) sub_funcs = sub_config_name_list.get(config_name) for sub_func in sub_funcs: sub_func(config_name, sub_func.func_name, cv, force=True) print 'config: ', config_name, ' saved' done_list.append(sheet_title) cv.save() if need_private_city_test: from logics.private_city import city_map_test