def writeCfg(cfg, ccfgPath): utils.make_sure_path(ccfgPath) #print(" ----> Write %s/Methods.lua "%(ccfgPath)) with codecs.open(ccfgPath + "/Methods.lua", "w", "utf-8") as f: f.write(tolua(cfg["done_methods"])) #print(" ----> Write %s/Types.lua "%(ccfgPath)) with codecs.open(ccfgPath + "/Types.lua", "w", "utf-8") as f: f.write( tolua({ "types": cfg["done_types"], "id2types": cfg["done_types_id"] })) #print(" ----> Write %s/Entities.lua "%(ccfgPath)) with codecs.open(ccfgPath + "/Entities.lua", "w", "utf-8") as f: f.write(tolua(cfg["done_entities"])) #print(" ----> Write %s/ProxyDefine.lua "%(ccfgPath)) with codecs.open(ccfgPath + "/ProxyDefine.lua", "w", "utf-8") as f: f.write(tolua(cfg["done_proxies"])) #print(" ----> Write %s/HadesUUID.lua "%(ccfgPath)) with codecs.open(ccfgPath + "/HadesUUID.lua", "w", "utf-8") as f: f.write(tolua(cfg["uuid"]))
def write(cfg, scfgPath): utils.make_sure_path(scfgPath) #print(" ----> Write %s/Types.json "%(scfgPath)) with codecs.open(scfgPath + "/Types.json", "w", "utf-8") as f: f.write( json.dumps( { "types": cfg["done_types"], "id2types": cfg["done_types_id"] }, sort_keys=True, indent=4)) #print(" ----> Write %s/Methods.json "%(scfgPath)) with codecs.open(scfgPath + "/Methods.json", "w", "utf-8") as f: f.write(json.dumps(cfg["done_methods"], sort_keys=True, indent=4)) #print(" ----> Write %s/Entities.json "%(scfgPath)) with codecs.open(scfgPath + "/Entities.json", "w", "utf-8") as f: #pprint(cfg["done_entities"]) f.write(json.dumps(cfg["done_entities"], sort_keys=True, indent=4)) #print(" ----> Write %s/ProxyDefine.json "%(scfgPath)) with codecs.open(scfgPath + "/ProxyDefine.json", "w", "utf-8") as f: f.write(json.dumps(cfg["done_proxies"], indent=4)) #print(" ----> Write %s/HadesUUID.json "%(scfgPath)) with codecs.open(scfgPath + "/HadesUUID.json", "w", "utf-8") as f: f.write(json.dumps(cfg["uuid"], sort_keys=True, indent=4))
def write(cfg, scfgPath): utils.make_sure_path(scfgPath) #print(" ----> Write %s/Servers.json "%(scfgPath)) with open(scfgPath + "/Servers.json", "w") as f: f.write(json.dumps(cfg["Servers"], sort_keys=True, indent=4)) #print(" ----> Write %s/Master.json "%(scfgPath)) with open(scfgPath + "/Master.json", "w") as f: f.write(json.dumps(cfg["Master"], sort_keys=True, indent=4)) #print(" ----> Write %s/Admin.json "%(scfgPath)) with open(scfgPath + "/Admin.json", "w") as f: f.write(json.dumps(cfg['Admin'], sort_keys=True, indent=4)) #print(" ----> Write %s/AdminUser.json "%(scfgPath)) with open(scfgPath + "/AdminUser.json", "w") as f: f.write(json.dumps(cfg['AdminUser'], sort_keys=True, indent=4)) #print(" ----> Write %s/Log4js.json "%(scfgPath)) with open(scfgPath + "/Log4js.json", "w") as f: f.write(json.dumps(cfg['Log4js'], sort_keys=True, indent=4)) with open(scfgPath + "/Platform.json", "w") as f: f.write(json.dumps(cfg['Platform'], sort_keys=True, indent=4)) with open(scfgPath + "/SpecialAccount.json", "w") as f: f.write(json.dumps(cfg['SpecialAccount'], sort_keys=True, indent=4)) #print(" ----> Write %s/Log.json "%(scfgPath)) #with open(scfgPath + "/Log.json", "w") as f: # f.write(json.dumps({"console": True}, sort_keys=True, indent=4)) #print(" ----> Write %s/Cluster.json "%(scfgPath)) with codecs.open(scfgPath + "/Cluster.json", "w", "utf-8") as f: f.write(json.dumps(cfg["Cluster"], sort_keys=True, ensure_ascii=False, indent=4)) #print(" ----> Write %s/Redis.json "%(scfgPath)) with open(scfgPath + "/Redis.json", "w") as f: f.write(json.dumps(cfg["Redis"], sort_keys=True, indent=4)) #print(" ----> Write %s/Mysql.json "%(scfgPath)) with open(scfgPath + "/Mysql.json", "w") as f: f.write(json.dumps(cfg["Mysql"], sort_keys=True, indent=4)) #print()
def writeScript(cfg, ccPath): utils.make_sure_path(ccPath) keys = utils.getObjSortedKeys(cfg['done_entities']) for ename in keys: ecfg = cfg['done_entities'][ename] if ecfg['etype'] != 0: continue rlpath = cfg["entities"][ename]['path'] if rlpath: rlpath += "/" epath = ccPath + "/" + rlpath if not os.path.exists(epath): os.makedirs(epath) method = epath + ename + ".lua" userCode = { "__private": [], "__require": [], "__global": [], "__property": [], "____old": {} } if os.path.exists(method): with codecs.open(method, "r", "utf-8") as f: #print(" ----> Load %s "%(method)) userCode = utils.importUserCode(f, AUTO_LUA_COMMENT) try: with codecs.open(method + ".tmp", "w", "utf-8") as f: exportLuaEntity(cfg, ename, ecfg, userCode, f) with codecs.open(method + ".tmp", "r", "utf-8") as f: with codecs.open(method, "w", "utf-8") as fw: fw.write(f.read()) except (Exception) as e: import traceback print("Failed export lua -> ", method, e.args) traceback.print_exc() finally: os.remove(method + ".tmp") #print()
def write(cfg, outPath): utils.make_sure_path(outPath) out = {} for ename, e in cfg['done_entities'].items(): if e["abstract"]: continue #print("Start Entity -> ", ename) generateEntity(out, cfg, ename, e) newPath = outPath + "/OrmModel.json" with codecs.open(newPath, "w", "utf-8") as f: f.write(json.dumps(out, indent=4)) # mapping = outPath + "/OrmMapping.json" # mapOut = generateMapping(out) # with open(mapping, "w") as f: # f.write(json.dumps(mapOut, indent = 4)) # if __name__ == "__main__": # print("len -> ", len(chars))
def write(cfg, scPath): keys = utils.getObjSortedKeys(cfg['done_entities']) for ename in keys: ecfg = cfg['done_entities'][ename] rlpath = cfg["entities"][ename]['path'] if rlpath: rlpath += "/" epath = scPath + "/" + rlpath utils.make_sure_path(epath) method = epath + ename + "Method.js" userCode = { "__private": [], "__require": [], "__global": [], "__property": [], "__public": [], "____old": {} } if os.path.exists(method): with codecs.open(method, "r", "utf-8") as f: #print(" ----> Load %s "%(method)) userCode = utils.importUserCode(f, AUTO_JS_COMMENT) #print(" ----> Write %s "%(method)) try: with codecs.open(method + ".tmp", "w", "utf-8") as f: exportJsEntityMethod(cfg, ename, ecfg, userCode, f) with codecs.open(method + ".tmp", "r", "utf-8") as f: with codecs.open(method, "w", "utf-8") as fw: fw.write(f.read()) except (Exception) as e: import traceback print("Failed export method -> ", method, e.args) traceback.print_exc() finally: os.remove(method + ".tmp")