@param dsrc : 当前行所在数据源信息 @return : None/KEYRET_NORMAL/KEYRET_EMPTY/KEYRET_IGNOR None 正常导出 KEYRET_NORMAL 不导出并且不提示 KEYRET_EMPTY 认为空行提示 KEYRET_IGNOR 认为该行忽略并提示 """ if value["gtype"] > 0: self.__gtype = value["gtype"] self.__gtypeName = value["gtypeName"] else: value["gtype"] = self.__gtype value["gtypeName"] = self.__gtypeName if key in self.__gids: raise ExportException("第 %d 行与第 %d 行的商品编号重复!" % (row + 1, self.__gids[key] + 1)) self.__gids[key] = row if value["costAmount"] <= 0: raise ExportException("第 %d 行是否忘记填写价格了?" % (row + 1)) # 导出信息 outInfo = TarsOutInfo(out, OutItemInfo1("Main", ExpInfo(exp1, csv1)), isWriteHeader=True, comment="兑换商品列表配置", servers=[ "exchangeserver", ])
# --------------------------------------------------------------------------------------- # 数据源信息,第二个参数表示作为标头的行,第三个参数表示数据内容的起始行(注意:第一行为 0) xlsx = tb_xlsx.getDataSource({ "1": r"1-开发环境\分红权\分红权.xlsx", "2": r"2-正式环境\分红权\分红权.xlsx", }[sys.argv[2]], "能量值兑换表", 0, 1) out = { "1": r"1-开发环境\分红权\point2bonus.conf", "2": r"2-正式环境\分红权\point2bonus.conf", }[sys.argv[2]] # --------------------------------------------------------------------------------------- # 导出表达式 # --------------------------------------------------------------------------------------- exp = { ex_key_row(): { "name": ex_str_col("名称"), "points": ex_int_col("积分"), "bonuses": ex_int_col("股权数") } } # --------------------------------------------------------------------------------------- # 导出信息 # --------------------------------------------------------------------------------------- outInfo = TarsOutInfo(out, TarsOutItemInfo("Main", ExpInfo(exp, xlsx)), comment="能量值与股权兑换映射表", servers="bonusserver")
@property def srcTexts(self): return [ xlsx1.getSrcText(), xlsx2.getSrcText(), xlsx3.getSrcText(), xlsx4.getSrcText() ] # --------------------------------------------------------------------------------------- # 导出信息 # --------------------------------------------------------------------------------------- # 全局参数设置 outInfo0 = TarsOutInfo(None, TarsOutItemInfo("Main", ExpInfo(exp0, xlsx0))) # 奖品 outInfo1 = TarsOutInfo( None, # 不单奖励物品单独写出文件 TarsOutItemInfo("rewardItems", ExpInfo(exp1, xlsx1))) # 抽奖类别 outInfo2 = TarsOutInfo(None, TarsOutItemInfo("ltypes", ExpInfo(exp2, xlsx2))) # 单独抽奖 outInfo3 = TarsOutInfo(None, OutItemInfo3("single", ExpInfo(exp3, xlsx3))) # 大盘池 outInfo4 = TarsOutInfo(out, OutItemInfo4("Main", ExpInfo(exp4, xlsx4)),
class OutItemInfo1(TarsOutItemInfo): def onRowScanning(self, datas, key, value, row, dsrc): """ 每解释一行时被调用,还没添加进 datas @param datas: 整个数据表 @param key : 当前解释到的行的 key @param value: 当前行数据值 @param row : 当前解释到的行索引 @param dsrc : 当前行所在数据源信息 @return : None/KEYRET_NORMAL/KEYRET_EMPTY/KEYRET_IGNOR None 正常导出 KEYRET_NORMAL 不导出并且不提示 KEYRET_EMPTY 认为空行提示 KEYRET_IGNOR 认为该行忽略并提示 """ typeItem = datas.get(key, OrderDict()) # 商品类别 datas[key] = typeItem if (value["item"]["payType"] == 1): # 如果是货币支付,则将 “元” 单位转化为 “分” 单位,即乘以 100 value["item"]["price"] *= 100 typeItem[value["storeID"]] = value["item"] return KEYRET_NORMAL # 导出信息 outInfo = TarsOutInfo( out, OutItemInfo1("Main", ExpInfo(exp1, csv1)), isWriteHeader = True, comment ="商店商品配置", servers = ["dbserver", "gameserver"])
None 正常导出 KEYRET_NORMAL 不导出并且不提示 KEYRET_EMPTY 认为空行提示 KEYRET_IGNOR 认为该行忽略并提示 """ if key not in datas: datas[key] = value sample = datas[key] casino = value.pop("casino") casinoID = casino.pop("id") sample[casinoID] = casino odds = 0 ai = OrderDict() aiInfos = casino["ai"] for lv, odd in aiInfos: ai[lv] = odd odds += odd casino["ai"] = ai if odds != 100: raise ExportException("第 %i 行的 ai 几率总值合计没有等于 100" % (row + 1)) return KEYRET_NORMAL # 导出信息 outInfo = TarsOutInfo(outFile, OutItemInfo("Main", ExpInfo(exp, csv)), isWriteHeader=True, comment="金币场撮合配置", servers=["casinoserver", "gameserver"])
KEYRET_EMPTY 认为空行提示 KEYRET_IGNOR 认为该行忽略并提示 """ dstuff = {} stuffs = value.pop("stuffs") index = 1 for stuff in stuffs: if stuff is None: continue else: dstuff[stuff[0]] = stuff[1] index += 1 value["stuffs"] = dstuff if not value.has_key("type"): return None return None # 导出信息 outInfo1 = TarsOutInfo( out1, # 导出文件 OutItemInfo1("Main", ExpInfo(exp1, csv1)), # 导出选项信息 isWriteHeader=True, comment="邮箱配置", servers="mailserver") outInfo2 = TarsOutInfo(out2, OutItemInfo2("Main", ExpInfo(exp2, csv2)), isWriteHeader=True, comment="邮件模板", servers="mailserver") outInfos = [outInfo1, outInfo2]
("currencyValue", ex_int_col("货币价值")), ("kitbagOrder", ex_int_col("摆放优先级")), ("useType", ex_int_col("使用类别")), ("useParam", ex_orign_col("使用参数")), ]) } class OutItemInfo(TarsOutItemInfo): __colNames = {} def onRowScanning(self, datas, key, value, row, dsrc): if (value.pop("discarded")): return KEYRET_NORMAL # 排除被废弃的行 if value["type"] == 3: # 如果具有有效时间,则一定不可叠加 if value["validTime"] > 0: value["overlapped"] = 0 # --------------------------------------------------------------------------------------- # 导出信息 # --------------------------------------------------------------------------------------- outInfo = TarsOutInfo( out, OutItemInfo("Main", ExpInfo(exp1, csv1), ExpInfo(exp2, csv2), ExpInfo(exp3, csv3)), # 三表合并导出 isWriteHeader=True, comment="物品配置", servers=["dbserver", "gameserver", "mailserver", "lotteryserver"])
raise ExportException("第 %d 行指定的前置任务类别不存在" % (row + 1)) if qid not in datas[qtypeid]: raise ExportException("第 %d 行指定的前置任务编号不存在" % (row + 1)) if not questEvents.hasEnumValue(qitem["eventid"]): raise ExportException("第 %d 行指定的 \”任务事件编号\“ 不存在" % (row + 1)) return KEYRET_NORMAL def onAllScanned(self, datas): datas.update(outInfo1.outItemInfos[0].datas) @property def srcTexts(self): return [xlsx1.getSrcText(), xlsx2.getSrcText()] # --------------------------------------------------------------------------------------- # 导出信息 # --------------------------------------------------------------------------------------- outInfo1 = TarsOutInfo( None, # 不导出文件 OutItemInfo1("Main", ExpInfo(exp1, xlsx1))) # 导出选项信息 outInfo2 = TarsOutInfo(out, OutItemInfo2("Main", ExpInfo(exp2, xlsx2)), isWriteHeader=True, comment="任务配置", servers="questserver") outInfos = [outInfo1, outInfo2]