From 0bcccb072e212b9f6d05a354be46bebbd0db47fe Mon Sep 17 00:00:00 2001 From: zrong Date: Wed, 4 Mar 2015 10:23:44 +0800 Subject: [PATCH 01/10] rename hhlc to xlc --- README.md | 37 ++++++++++++++++++------------------- {hhlc => xlc}/__init__.py | 0 {hhlc => xlc}/base.py | 0 {hhlc => xlc}/conf.py | 0 {hhlc => xlc}/dirconf.py | 0 {hhlc => xlc}/etc.py | 0 {hhlc => xlc}/tocsv.py | 0 {hhlc => xlc}/tolua.py | 0 8 files changed, 18 insertions(+), 19 deletions(-) rename {hhlc => xlc}/__init__.py (100%) rename {hhlc => xlc}/base.py (100%) rename {hhlc => xlc}/conf.py (100%) rename {hhlc => xlc}/dirconf.py (100%) rename {hhlc => xlc}/etc.py (100%) rename {hhlc => xlc}/tocsv.py (100%) rename {hhlc => xlc}/tolua.py (100%) diff --git a/README.md b/README.md index d7f3532..c2c91f1 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -配置文件 -====== +转换 Excel 文档成为 CSV 和 LUA 格式 +=================================== -* 文档作者: zm -* 最后更新: 2014-12-09 - -该Python库用于保存和转换黄鹤楼项目中的配置文件。 +- 作者: zm [zrong](http://zengrong.net) +- 创建: 2014-12-09 +- 修改: 2015-03-04 将模块名称从 hhlc 改为 xlc。 # 安装 @@ -19,34 +18,34 @@ Windows 系统,若 pip 命令不可用,可使用下面的命令: 依赖库文件可以是本地文件或者 url,下面两个地址都可用: ../client/requirements.txt - http://192.168.18.18/project/hhl/tool/requirements.txt + http://192.168.18.18/project/1201/tool/requirements.txt # 使用 ## 作为库使用 -### 引用hhlc库 +### 引用 xlc 库 - import hhlc + import xlc ### 参数说明 -* xls +- xls Excel 文件和配置文件目录 -* export +- export 最终文件的输出目录 -* tmpl +- tmpl 模版文件的目录 -* command +- command 执行的命令, list类型, 传空list表示转换所有配置文件 -* ptype -指定转换配置文件的类型, 如all/csv/lua +- ptype +指定转换配置文件的类型, 如 all/csv/lua - hhlc.main(xls, export, command, ptype) + xlc.main(xls, export, command, ptype) ### 转换所有配置文件到export路径 - hhlc.main( + xlc.main( "D:\\works\\hhl\\projects\\config\\xls", "D:\\works\\hhl\\projects\\config\\export", "D:\\works\\hhl\\projects\\config\\templates", @@ -56,7 +55,7 @@ Excel 文件和配置文件目录 ### 转换指定的一个或多个配置文件到export路径 - hhlc.main( + xlc.main( "D:\\works\\hhl\\projects\\config\\xls", "D:\\works\\hhl\\projects\\config\\export", "D:\\works\\hhl\\projects\\config\\templates", @@ -66,7 +65,7 @@ Excel 文件和配置文件目录 ### 转换指定类型的配置文件, 并指定导出路径 - hhlc.main( + xlc.main( "D:\\works\\hhl\\projects\\config\\xls", "D:\\works\\hhl\\projects\\config\\export", "D:\\works\\hhl\\projects\\config\\templates", diff --git a/hhlc/__init__.py b/xlc/__init__.py similarity index 100% rename from hhlc/__init__.py rename to xlc/__init__.py diff --git a/hhlc/base.py b/xlc/base.py similarity index 100% rename from hhlc/base.py rename to xlc/base.py diff --git a/hhlc/conf.py b/xlc/conf.py similarity index 100% rename from hhlc/conf.py rename to xlc/conf.py diff --git a/hhlc/dirconf.py b/xlc/dirconf.py similarity index 100% rename from hhlc/dirconf.py rename to xlc/dirconf.py diff --git a/hhlc/etc.py b/xlc/etc.py similarity index 100% rename from hhlc/etc.py rename to xlc/etc.py diff --git a/hhlc/tocsv.py b/xlc/tocsv.py similarity index 100% rename from hhlc/tocsv.py rename to xlc/tocsv.py diff --git a/hhlc/tolua.py b/xlc/tolua.py similarity index 100% rename from hhlc/tolua.py rename to xlc/tolua.py From 1f287acced19f14b4018366ebfc02b3706db97e8 Mon Sep 17 00:00:00 2001 From: zrong Date: Wed, 4 Mar 2015 11:11:50 +0800 Subject: [PATCH 02/10] update package name and README --- README.md | 37 +++++++++++++++++++++++++++---------- xlc/__init__.py | 23 ++++------------------- xlc/conf.py | 12 ++++++------ xlc/etc.py | 3 ++- xlc/tocsv.py | 4 ++-- xlc/tolua.py | 9 +++++---- 6 files changed, 46 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index c2c91f1..3b958c7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ - 创建: 2014-12-09 - 修改: 2015-03-04 将模块名称从 hhlc 改为 xlc。 -# 安装 +# 1. 安装 第一次使用时,必须先进行安装以保证依赖库存在。可以使用下面的方式调用 pip 来安装依赖库: @@ -20,15 +20,14 @@ Windows 系统,若 pip 命令不可用,可使用下面的命令: ../client/requirements.txt http://192.168.18.18/project/1201/tool/requirements.txt -# 使用 +# 2. 使用 -## 作为库使用 +## 2.1 转换配置文件 -### 引用 xlc 库 +调用方式如下: import xlc - -### 参数说明 + xlc.call(xls, export, templ, command, ptype) - xls Excel 文件和配置文件目录 @@ -41,11 +40,10 @@ Excel 文件和配置文件目录 - ptype 指定转换配置文件的类型, 如 all/csv/lua - xlc.main(xls, export, command, ptype) ### 转换所有配置文件到export路径 - xlc.main( + xlc.call( "D:\\works\\hhl\\projects\\config\\xls", "D:\\works\\hhl\\projects\\config\\export", "D:\\works\\hhl\\projects\\config\\templates", @@ -55,7 +53,7 @@ Excel 文件和配置文件目录 ### 转换指定的一个或多个配置文件到export路径 - xlc.main( + xlc.call( "D:\\works\\hhl\\projects\\config\\xls", "D:\\works\\hhl\\projects\\config\\export", "D:\\works\\hhl\\projects\\config\\templates", @@ -65,10 +63,29 @@ Excel 文件和配置文件目录 ### 转换指定类型的配置文件, 并指定导出路径 - xlc.main( + xlc.call( "D:\\works\\hhl\\projects\\config\\xls", "D:\\works\\hhl\\projects\\config\\export", "D:\\works\\hhl\\projects\\config\\templates", ["hero", "skill"], "lua" ) + +## 2.3 转换技能配置文件(与 ET 工具配合使用) + +调用方式如下: + + import xlc.etc + xlc.etc.call(heroPath, sszPath, exportPath) + +- heroPath ET 工具使用的英雄 JSON 配置文件路径 +- sszPath ET 工具使用的其他 JSON 配置 +- exportPath 导出的配置文件路径 + +范例代码: + + xlc.etc.call( + "D:\\works\\hhl\\projects\\resource\\art", + "D:\\works\\hhl\\projects\\resource\\art\\ssz", + "D:\\works\\hhl\\projects\\resource\\skill" + ) diff --git a/xlc/__init__.py b/xlc/__init__.py index ab66a94..997f506 100644 --- a/xlc/__init__.py +++ b/xlc/__init__.py @@ -3,9 +3,9 @@ # Creation 2014-09-26 import os -from zrong.base import getFiles -from hhlc.conf import Parser, ParseError -import hhlc.dirconf as dirconf +from zrong.base import get_files +from xlc.conf import Parser, ParseError +import xlc.dirconf as dirconf # 排除非模块文件 @@ -46,7 +46,7 @@ def call(xls, export, tmpl, command=[], ptype="all"): elif ptype == "csv": dirconf.updateCsvPath(export) - files = filter(excludeFiles, getFiles(dirconf.xls_path, ["py"])) + files = filter(excludeFiles, get_files(dirconf.xls_path, ["py"])) if isinstance(command, list) and len(command) != 0: files = get_theModule(files, command) # + ".py" @@ -62,18 +62,3 @@ def callEtc(heroPath, sszPath, exportPath): import hhlc.etc as etc # import etc etc.call(heroPath, sszPath, exportPath) - -if __name__ == '__main__': - callDt( - "D:\\works\\hhl\\projects\\config\\xls", - "D:\\works\\hhl\\projects\\client\\src\\conf", - "D:\\works\\hhl\\projects\\config\\templates", - ["skill"], - "lua") - - # callEtc( - # "D:\\works\\hhl\\projects\\resource\\art", - # "D:\\works\\hhl\\projects\\resource\\art\\ssz", - # "D:\\works\\hhl\\projects\\resource\\skill" - # ) - diff --git a/xlc/conf.py b/xlc/conf.py index d70d95e..40ca91f 100644 --- a/xlc/conf.py +++ b/xlc/conf.py @@ -4,10 +4,10 @@ import os import xlrd -from zrong.base import getFiles, readFile -from hhlc.tocsv import Tocsv -from hhlc.tolua import Tolua -import hhlc.dirconf as dirconf +from zrong.base import (read_file) +from xlc.tocsv import Tocsv +from xlc.tolua import Tolua +import xlc.dirconf as dirconf class ParseError(Exception): @@ -34,7 +34,7 @@ def parseModules(self, files): for path in files: print("parse file: " + os.path.basename(path)) - self.module = self.sheetCheck(eval(readFile(path))) + self.module = self.sheetCheck(eval(read_file(path))) for sheet in self.module.get("sheets"): self.parseSheet(sheet) @@ -100,4 +100,4 @@ def readXls(self, sheet): __data = [__table.row_values(i) for i in range(nrows)] - return __data \ No newline at end of file + return __data diff --git a/xlc/etc.py b/xlc/etc.py index 7352a90..4eca93f 100644 --- a/xlc/etc.py +++ b/xlc/etc.py @@ -3,11 +3,12 @@ # etc = effect tool convertor # Author zm # Creation 2014-09-26 -# Modification zrong 2015-01-09 +# Modification zrong 2015-03-04 import re import os import json +from zrong import slog from zrong.base import (write_file, read_file, get_files, slog) diff --git a/xlc/tocsv.py b/xlc/tocsv.py index 9b986ce..022ca6f 100644 --- a/xlc/tocsv.py +++ b/xlc/tocsv.py @@ -4,8 +4,8 @@ import os import csv -from hhlc.base import Tobase, Totype -import hhlc.dirconf as dirconf +from xlc.base import Tobase, Totype +import xlc.dirconf as dirconf class Tocsv(Tobase): diff --git a/xlc/tolua.py b/xlc/tolua.py index 69940ee..a0fcb75 100644 --- a/xlc/tolua.py +++ b/xlc/tolua.py @@ -1,11 +1,12 @@ # parseLua.py # Author zm # Creation 2014-09-29 +# Modification 2015-03-04 zrong import os -from zrong.base import writeByTempl -from hhlc.base import Tobase, Totype -import hhlc.dirconf as dirconf +from zrong.base import write_by_templ +from xlc.base import Tobase, Totype +import xlc.dirconf as dirconf class Tolua(Tobase): @@ -151,7 +152,7 @@ def _createFile(self, str, true_name): self.chkDirPath(filePath) - writeByTempl( + write_by_templ( os.path.join(dirconf.temp_path, "%s.lua" % self.getPlanKey("template", "default")), filePath, From 7ddb77e8c300c7ac645e500208c2ccb6c1e1f093 Mon Sep 17 00:00:00 2001 From: zrong Date: Wed, 4 Mar 2015 11:56:27 +0800 Subject: [PATCH 03/10] update ssetup.py --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 6d6f4b7..b40b272 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ entry_points = { 'console_scripts': [ - 'hhlc = hhlc:main', + 'xlc = xlc:call', ] } @@ -32,13 +32,13 @@ # for root, dirs, files in os.walk('bin')] setup( - name="hhlc", - version="0.2.4", + name="xlc", + version="0.2.6", url='http://zengrong.net/', author='zrong', author_email='zrongzrong@gmail.com', description="Convert xls to lua and csv file.", - packages=['hhlc'], + packages=['xlc'], classifiers=classifiers, #include_package_data=True, #package_data=package_data, From 736931e3efa1b8f34da848d12f8e9ea8b59c9071 Mon Sep 17 00:00:00 2001 From: zm Date: Mon, 9 Mar 2015 15:28:06 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=B0=86=E6=B8=B8=E6=88=8F=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E9=83=A8=E5=88=86=E5=88=86=E7=A6=BB=E6=88=90?= =?UTF-8?q?=E5=87=BA=E6=9D=A5,=20=E6=88=90=E4=B8=BA=E6=A8=A1=E7=89=88?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xlc/etc.py | 86 +++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 49 deletions(-) diff --git a/xlc/etc.py b/xlc/etc.py index 4eca93f..112b827 100644 --- a/xlc/etc.py +++ b/xlc/etc.py @@ -18,6 +18,11 @@ def __init__(self, export): self.export = export self.file_dir = os.getcwd() + def parseTmpl(self, path): + jsontxt = read_file(os.path.join(path, "tmpl.json")) + self.tmpl = json.loads(jsontxt) + pass + def parseConf(self, obj, fileName): start = '["%s"]=\n' end = '\n\n' @@ -36,7 +41,7 @@ def parseHero(self, files): for path in files: heroId = os.path.basename(path).split('.')[0] - print("parse ect:", heroId) + # print("parse ect:", heroId) jsontxt = read_file(path) # replace // jsontxt = re.sub(r'\/\/.*$', '', jsontxt, flags=re.M) @@ -86,51 +91,32 @@ def _parseSkillKey(self, key, heroId): def getSkill(self, tab, id, obj): _tab = self._tab(tab) - # print(len(args)) - return _tab + 'id=' + id + ',\n' + \ - _tab + 'effects_b=' + self.getValue(obj["effects_b"]) + ',\n' + \ - _tab + 'effects_b_no=' + self.getTable(obj["effects_b_no"]) + ',\n' + \ - _tab + 'effects_f=' + self.getValue(obj["effects_f"]) + ',\n' + \ - _tab + 'effects_f_no=' + self.getTable(obj["effects_f_no"]) + ',\n' + \ - _tab + 't_sex=' + self.getValue(obj["t_sex"]) + ',\n' + \ - _tab + 't_syb=' + self.getValue(obj["t_syb"]) + ',\n' + \ - _tab + 't_sb=' + self.getValue(obj["t_sb"]) + ',\n' + \ - _tab + 'ce_b=' + self.getValue(obj["ce_b"]) + ',\n' + \ - _tab + 'ce_b_no=' + self.getValue(obj["ce_b_no"]) + ',\n' + \ - _tab + 'ce_f=' + self.getValue(obj["ce_f"]) + ',\n' + \ - _tab + 'ce_f_no=' + self.getValue(obj["ce_f_no"]) + ',\n' + \ - _tab + 't_syx=' + self.getValue(obj["t_syx"]) + ',\n' + \ - _tab + 't_sd=' + self.getValue(obj["t_sd"]) + ',\n' + \ - _tab + 'zoom=' + self.getValue(obj["zoom"]) + ',\n' + \ - _tab + 'zoom_no=' + self.getValue(obj["zoom_no"]) + ',\n' + \ - _tab + 'shake=' + self.getValue(obj["shake"]) + ',\n' + \ - _tab + 'shake_no=' + self.getValue(obj["shake_no"]) + ',\n' + \ - _tab + 'shine1=' + self.getValue(obj["shine1"]) + ',\n' + \ - _tab + 'shine1_no=' + self.getValue(obj["shine1_no"]) + ',\n' + \ - _tab + 'shine2=' + self.getValue(obj["shine2"]) + ',\n' + \ - _tab + 'shine2_no=' + self.getValue(obj["shine2_no"]) + tmpStr = _tab + 'id=' + id + ',\n' + + for val in self.tmpl["hero_action"]: + tmpStr += _tab + \ + val[0] + '=' + \ + self.getValue(obj[val[0]], val[1]) + \ + ',\n' + + return tmpStr[0:-2] def _parseEnemy_action(self, tab, obj): _tab = self._tab(tab) - return ',\n' + \ - _tab + 'e_effects_no=' + self.getValue(obj["e_effects_no"]) + ',\n' + \ - _tab + 'e_shine1=' + self.getValue(obj["e_shine1"]) + ',\n' + \ - _tab + 'e_shine1_no=' + self.getValue(obj["e_shine1_no"]) + ',\n' + \ - _tab + 'e_shine2=' + self.getValue(obj["e_shine2"]) + ',\n' + \ - _tab + 'e_shine2_no=' + self.getValue(obj["e_shine2_no"]) + ',\n' + \ - _tab + 'e_desc=' + self.getValue(obj["e_desc"]) + ',\n' + \ - _tab + 'e_desc_no=' + self.getValue(obj["e_desc_no"]) + ',\n' + \ - _tab + 'e_icon=' + self.getValue(obj["e_icon"]) + ',\n' + \ - _tab + 'e_icon_no=' + self.getValue(obj["e_icon_no"]) + ',\n' + \ - _tab + 'e_effects_b=' + self.getValue(obj["e_effects_b"]) + ',\n' + \ - _tab + 'e_effects_b_no=' + self.getValue(obj["e_effects_b_no"]) + ',\n' + \ - _tab + 'e_effects_f=' + self.getValue(obj["e_effects_f"]) + ',\n' + \ - _tab + 'e_effects_f_no=' + self.getValue(obj["e_effects_f_no"]) + ',\n' + \ - _tab + 'e_arm=' + self.getValue(obj["e_arm"]) + ',\n' + \ - _tab + 'e_arm_no=' + self.getValue(obj["e_arm_no"]) + ',\n' + \ - _tab + 'e_label=' + self.getValue(obj["e_label"]) + '\n' - - def getValue(self, val): + tmpStr = ',\n' + + for val in self.tmpl["enemy_action"]: + tmpStr += _tab + \ + val[0] + '=' + \ + self.getValue(obj[val[0]], val[1]) + \ + ',\n' + + return tmpStr[0:-2] + '\n' + + def getValue(self, val, fmt): + if fmt == "table": + return self.getTable(val) + val = str(val) # '10.0' try: tmp = float(val) # 10.0 @@ -190,16 +176,18 @@ def confFiles(path): # 获取play.json -def playFiles(path): - __fname = os.path.basename(path) - for exclude in ["play.json"]: - if exclude == __fname: - return True - return False +# def playFiles(path): +# __fname = os.path.basename(path) +# for exclude in ["play.json"]: +# if exclude == __fname: +# return True +# return False def call(heroPath, sszPath, exportPath): parser = Parser(exportPath) + #parse tmpl + parser.parseTmpl(heroPath) # parse heros files = filter(herosFiles, get_files(heroPath, ["json"])) From 7481977fdc54a9e1d9c55f81c5d8079a537eeac5 Mon Sep 17 00:00:00 2001 From: zrong Date: Wed, 1 Apr 2015 10:32:48 +0800 Subject: [PATCH 05/10] update version to 0.2.7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b40b272..25d3f96 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( name="xlc", - version="0.2.6", + version="0.2.7", url='http://zengrong.net/', author='zrong', author_email='zrongzrong@gmail.com', From e56a8db557e8e7af90ca73f017befc9eb94ec8fe Mon Sep 17 00:00:00 2001 From: zm Date: Wed, 1 Apr 2015 10:45:34 +0800 Subject: [PATCH 06/10] 0.2.8 --- setup.py | 2 +- xlc/__init__.py | 15 +++++++++++++++ xlc/etc.py | 18 ++++++++++-------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 25d3f96..35e2340 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( name="xlc", - version="0.2.7", + version="0.2.8", url='http://zengrong.net/', author='zrong', author_email='zrongzrong@gmail.com', diff --git a/xlc/__init__.py b/xlc/__init__.py index 997f506..bc2c201 100644 --- a/xlc/__init__.py +++ b/xlc/__init__.py @@ -62,3 +62,18 @@ def callEtc(heroPath, sszPath, exportPath): import hhlc.etc as etc # import etc etc.call(heroPath, sszPath, exportPath) + +# if __name__ == '__main__': + # callDt( + # "D:\\works\\hhl\\projects\\config\\xls", + # "D:\\works\\hhl\\projects\\client\\src\\conf", + # "D:\\works\\hhl\\projects\\config\\templates", + # ["skill"], + # "lua") + + # callEtc( + # "D:\\works\\hhl\\projects\\resource\\art", + # "D:\\works\\hhl\\projects\\resource\\art\\ssz", + # "D:\\works\\hhl\\projects\\resource\\skill" + # ) + diff --git a/xlc/etc.py b/xlc/etc.py index 112b827..78c8570 100644 --- a/xlc/etc.py +++ b/xlc/etc.py @@ -94,10 +94,11 @@ def getSkill(self, tab, id, obj): tmpStr = _tab + 'id=' + id + ',\n' for val in self.tmpl["hero_action"]: - tmpStr += _tab + \ - val[0] + '=' + \ - self.getValue(obj[val[0]], val[1]) + \ - ',\n' + if val[0] in obj: + tmpStr += _tab + \ + val[0] + '=' + \ + self.getValue(obj[val[0]], val[1]) + \ + ',\n' return tmpStr[0:-2] @@ -106,10 +107,11 @@ def _parseEnemy_action(self, tab, obj): tmpStr = ',\n' for val in self.tmpl["enemy_action"]: - tmpStr += _tab + \ - val[0] + '=' + \ - self.getValue(obj[val[0]], val[1]) + \ - ',\n' + if val[0] in obj: + tmpStr += _tab + \ + val[0] + '=' + \ + self.getValue(obj[val[0]], val[1]) + \ + ',\n' return tmpStr[0:-2] + '\n' From 2e25882f3cccdf7facf9fe79adf028440195bfcf Mon Sep 17 00:00:00 2001 From: zm Date: Tue, 7 Apr 2015 11:35:13 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E5=B0=86=E5=AF=BC=E5=87=BAcsv=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?utf-8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 2 +- xlc/tocsv.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 35e2340..69a6f9c 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( name="xlc", - version="0.2.8", + version="0.2.9", url='http://zengrong.net/', author='zrong', author_email='zrongzrong@gmail.com', diff --git a/xlc/tocsv.py b/xlc/tocsv.py index 022ca6f..65f70a6 100644 --- a/xlc/tocsv.py +++ b/xlc/tocsv.py @@ -27,7 +27,7 @@ def parse(self, plan, head, data): self.chkDirPath(filePath) - csvfile = open(filePath, 'w', newline='') + csvfile = open(filePath, 'w', encoding='utf8', newline='') writer = csv.writer(csvfile) # head From a2b4141062e9f0be08c2cfc842019e4256b30cef Mon Sep 17 00:00:00 2001 From: zm Date: Fri, 17 Apr 2015 09:59:36 +0800 Subject: [PATCH 08/10] =?UTF-8?q?ignore=5Fhead=20=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xlc/tocsv.py | 6 +++++- xlc/tolua.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/xlc/tocsv.py b/xlc/tocsv.py index 65f70a6..8c9f870 100644 --- a/xlc/tocsv.py +++ b/xlc/tocsv.py @@ -49,11 +49,15 @@ def parse(self, plan, head, data): __head = head[conf['index']] elif "head" in conf: __head = conf['head'] + elif "key" in conf: + __head = conf['key'] + # 如果数据为空, 并且指定的head在忽略列表就不添加此行 if __head and __head in plan.get("ignore_head"): addRow = False break - if addRow: writer.writerow(__row) + if addRow: + writer.writerow(__row) csvfile.close() diff --git a/xlc/tolua.py b/xlc/tolua.py index a0fcb75..024417d 100644 --- a/xlc/tolua.py +++ b/xlc/tolua.py @@ -44,12 +44,16 @@ def parse(self, plan, head, data): __head = head[conf['index']] elif "head" in conf: __head = conf['head'] + elif "key" in conf: + __head = conf['key'] + # 如果数据为空, 并且指定的head在忽略列表就不添加此行 if __head and __head in plan.get("ignore_head"): addRow = False break __rowStr += end - if addRow: tmpStr += __rowStr + if addRow: + tmpStr += __rowStr self._createFile(tmpStr, plan.get("true_name")) From f929373e41f99056db122d8b689bfbceb2fdbf63 Mon Sep 17 00:00:00 2001 From: zm Date: Fri, 17 Apr 2015 10:13:31 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7+1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 69a6f9c..6756370 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( name="xlc", - version="0.2.9", + version="0.3.0", url='http://zengrong.net/', author='zrong', author_email='zrongzrong@gmail.com', From 06c3b3834b5ffce5bc9e9fbf023490d9246617b5 Mon Sep 17 00:00:00 2001 From: zm Date: Wed, 17 Jun 2015 14:58:54 +0800 Subject: [PATCH 10/10] xlc .replace("\n", "\\n") --- setup.py | 2 +- xlc/base.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 6756370..fdab063 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( name="xlc", - version="0.3.0", + version="0.3.1", url='http://zengrong.net/', author='zrong', author_email='zrongzrong@gmail.com', diff --git a/xlc/base.py b/xlc/base.py index 52dffbb..c9db693 100644 --- a/xlc/base.py +++ b/xlc/base.py @@ -59,7 +59,7 @@ def _initFuns(self): pass def defaultStr(self, *args): - return '"%s"' % str(args[0]) + return '"%s"' % str(args[0]).replace("\n", "\\n") def defaultInt(self, *args): if args[0] != 0 and not args[0]: