Commit 7ee47f0a by xxlv

Fix typo

parent 1b2386f8
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="1abc04e8-e167-42cd-98ea-074bbb2150ed" name="Default" comment=""> <list default="true" id="1abc04e8-e167-42cd-98ea-074bbb2150ed" name="Default" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gen.py" beforeDir="false" afterPath="$PROJECT_DIR$/gen.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/gen.py" beforeDir="false" afterPath="$PROJECT_DIR$/gen.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
...@@ -18,11 +16,14 @@ ...@@ -18,11 +16,14 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name=".gitignore" pinned="false" current-in-tab="true"> <file leaf-file-name="gen.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/.gitignore"> <entry file="file://$PROJECT_DIR$/gen.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15"> <state relative-caret-position="431">
<caret line="1" column="5" selection-start-line="1" selection-start-column="5" selection-end-line="1" selection-end-column="5" /> <caret line="327" column="16" lean-forward="true" selection-start-line="327" selection-start-column="16" selection-end-line="327" selection-end-column="16" />
<folding>
<element signature="e#42#51#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
<find>clean_tmp</find> <find>clean_tmp</find>
<find>gen_po</find> <find>gen_po</find>
<find>config_mybatis</find> <find>config_mybatis</find>
<find>compile_table</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>${PLACE}</replace> <replace>${PLACE}</replace>
...@@ -53,8 +55,8 @@ ...@@ -53,8 +55,8 @@
<option value="$PROJECT_DIR$/template/${PLACE}Biz.java" /> <option value="$PROJECT_DIR$/template/${PLACE}Biz.java" />
<option value="$PROJECT_DIR$/heml.py" /> <option value="$PROJECT_DIR$/heml.py" />
<option value="$PROJECT_DIR$/tmp/generatorConfig.xml" /> <option value="$PROJECT_DIR$/tmp/generatorConfig.xml" />
<option value="$PROJECT_DIR$/gen.py" />
<option value="$PROJECT_DIR$/.gitignore" /> <option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/gen.py" />
</list> </list>
</option> </option>
</component> </component>
...@@ -88,6 +90,11 @@ ...@@ -88,6 +90,11 @@
<item name="quick_tpl" type="b2602c69:ProjectViewProjectNode" /> <item name="quick_tpl" type="b2602c69:ProjectViewProjectNode" />
<item name="quick_tpl" type="462c0819:PsiDirectoryNode" /> <item name="quick_tpl" type="462c0819:PsiDirectoryNode" />
</path> </path>
<path>
<item name="quick_tpl" type="b2602c69:ProjectViewProjectNode" />
<item name="quick_tpl" type="462c0819:PsiDirectoryNode" />
<item name="template" type="462c0819:PsiDirectoryNode" />
</path>
</expand> </expand>
<select /> <select />
</subPane> </subPane>
...@@ -208,8 +215,8 @@ ...@@ -208,8 +215,8 @@
<window_info anchor="bottom" id="Version Control" order="7" /> <window_info anchor="bottom" id="Version Control" order="7" />
<window_info anchor="bottom" id="Python Console" order="9" /> <window_info anchor="bottom" id="Python Console" order="9" />
<window_info anchor="bottom" id="Run" order="2" /> <window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Terminal" order="7" visible="true" weight="0.329718" /> <window_info active="true" anchor="bottom" id="Terminal" order="7" visible="true" weight="0.329718" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25235197" /> <window_info content_ui="combo" id="Project" order="0" weight="0.25235197" />
<window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" /> <window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" />
<window_info anchor="right" id="Database" order="3" /> <window_info anchor="right" id="Database" order="3" />
<window_info anchor="right" id="SciView" order="5" /> <window_info anchor="right" id="SciView" order="5" />
...@@ -275,13 +282,6 @@ ...@@ -275,13 +282,6 @@
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/gen.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="12" column="17" lean-forward="true" selection-start-line="12" selection-start-column="17" selection-end-line="12" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/template/${PLACE}Facade.java"> <entry file="file://$PROJECT_DIR$/template/${PLACE}Facade.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165"> <state relative-caret-position="165">
...@@ -471,13 +471,6 @@ ...@@ -471,13 +471,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/template/${PLACE}Biz.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="14" column="51" lean-forward="true" selection-start-line="14" selection-start-column="51" selection-end-line="14" selection-end-column="51" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/template/${PLACE}BizImpl.java"> <entry file="file://$PROJECT_DIR$/template/${PLACE}BizImpl.java">
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor" />
</entry> </entry>
...@@ -535,16 +528,6 @@ ...@@ -535,16 +528,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/gen.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="373">
<caret line="207" column="21" selection-start-line="207" selection-start-column="21" selection-end-line="207" selection-end-column="21" />
<folding>
<element signature="e#42#51#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tmp/About.java"> <entry file="file://$PROJECT_DIR$/tmp/About.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210"> <state relative-caret-position="210">
...@@ -555,7 +538,31 @@ ...@@ -555,7 +538,31 @@
<entry file="file://$PROJECT_DIR$/.gitignore"> <entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15"> <state relative-caret-position="15">
<caret line="1" column="5" selection-start-line="1" selection-start-column="5" selection-end-line="1" selection-end-column="5" /> <caret line="1" column="5" lean-forward="true" selection-start-line="1" selection-start-column="5" selection-end-line="1" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/template/${PLACE}Biz.java">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="21" selection-start-column="21" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file:///usr/lib/python2.7/re.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="197">
<caret line="137" column="4" selection-start-line="137" selection-start-column="4" selection-end-line="137" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/gen.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="431">
<caret line="327" column="16" lean-forward="true" selection-start-line="327" selection-start-column="16" selection-end-line="327" selection-end-column="16" />
<folding>
<element signature="e#42#51#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
......
...@@ -195,11 +195,10 @@ def gen_po(res_name, project_target_path): ...@@ -195,11 +195,10 @@ def gen_po(res_name, project_target_path):
local_mybatis_config_path = local_mybatis_config["tmp_mybatis_path"] local_mybatis_config_path = local_mybatis_config["tmp_mybatis_path"]
po_path = "{}/{}".format(MYBATIS_GEN_JAVA_PATH,"/".join(local_mybatis_config["po_path"].split("."))) po_path = "{}/{}".format(MYBATIS_GEN_JAVA_PATH, "/".join(local_mybatis_config["po_path"].split(".")))
print(po_path) print(po_path)
gen_po_cmd = """ gen_po_cmd = """
java -jar {}/mybatis-generator-core-1.3.6.jar -configfile {} -overwrite java -jar {}/mybatis-generator-core-1.3.6.jar -configfile {} -overwrite
""".format(JAR_PATH, local_mybatis_config_path) """.format(JAR_PATH, local_mybatis_config_path)
...@@ -209,13 +208,12 @@ def gen_po(res_name, project_target_path): ...@@ -209,13 +208,12 @@ def gen_po(res_name, project_target_path):
print("----------------------------------------") print("----------------------------------------")
os.system(gen_po_cmd) os.system(gen_po_cmd)
with open("{}/{}.java".format(po_path,res_name), "r+") as f: with open("{}/{}.java".format(po_path, res_name), "r+") as f:
po = f.read() po = f.read()
return po return po
# 编译内容
def compile_content(res_name, compile_table, origin, tmp, project_target_path): def compile_content(res_name, compile_table, origin, tmp, project_target_path):
""" """
编译内容 编译内容
...@@ -252,15 +250,20 @@ def compile_content(res_name, compile_table, origin, tmp, project_target_path): ...@@ -252,15 +250,20 @@ def compile_content(res_name, compile_table, origin, tmp, project_target_path):
return identity return identity
# 获取编译后的名字
def compile(body, compile_table): def compile(body, compile_table):
"""
编译
:param body:
:param compile_table:
:return:
"""
for d, v in compile_table.iteritems(): for d, v in compile_table.iteritems():
body = body.replace(d, v) body = body.replace(d, v)
return body return body
# clean tmp dir
def clean_tmp(): def clean_tmp():
""" """
清空临时目录 清空临时目录
...@@ -276,7 +279,6 @@ def clean_tmp(): ...@@ -276,7 +279,6 @@ def clean_tmp():
print("清空目录 {}".format(TMP)) print("清空目录 {}".format(TMP))
# gen
def gen(res_name, look_path): def gen(res_name, look_path):
""" """
核心逻辑 核心逻辑
...@@ -294,6 +296,8 @@ def gen(res_name, look_path): ...@@ -294,6 +296,8 @@ def gen(res_name, look_path):
PROJECT_TARGET_PATH = parse_ydl_project(look_path) PROJECT_TARGET_PATH = parse_ydl_project(look_path)
print(PROJECT_TARGET_PATH)
if (PROJECT_TARGET_PATH): if (PROJECT_TARGET_PATH):
print("解析YDL Project 成功!") print("解析YDL Project 成功!")
else: else:
...@@ -303,17 +307,42 @@ def gen(res_name, look_path): ...@@ -303,17 +307,42 @@ def gen(res_name, look_path):
compile_table = dict() compile_table = dict()
compile_table['${PLACE}'] = "{}{}".format(res_name[0].upper(), res_name[1:]) compile_table['${PLACE}'] = "{}{}".format(res_name[0].upper(), res_name[1:])
compile_table['${PLACE_VAR}'] = "{}{}".format(res_name[0].lower(), res_name[1:]) compile_table['${PLACE_VAR}'] = "{}{}".format(res_name[0].lower(), res_name[1:])
import re
intf = PROJECT_TARGET_PATH["intf_po_path"]
p = re.compile("[\s\S]*\/(.+)\-intf\/[\s\S]*")
matches = re.match(p, intf)
if matches is not None:
package = matches.group(1)
else:
package = ""
print("抱歉,无法在{} 中解析到包规则".format(look_path))
exit(-1)
package_list = package.split("-")
if len(package_list) != 2:
print("包解析失败啦~")
exit(-1)
package_level1 = package_list[0]
package_level2 = package_list[1]
compile_table['${PACKAGE_LEVEL1}'] = "{}".format(package_level1)
compile_table['${PACKAGE_LEVEL2}'] = "{}".format(package_level2)
print("--------------------------------------") print("--------------------------------------")
print("编译常量表") print("编译常量表")
print("--------------------------------------") print("--------------------------------------")
# 编译文件 # 编译文件
for root, dirs, files in os.walk(DIR, False): for root, dirs, files in os.walk(DIR, False):
for file in files: for file in files:
if (file[0] == "$"): if (file[0] == "$"):
compiled_file = compile_content(res_name, compile_table, os.path.join(root, file), TMP, compiled_file = compile_content(res_name, compile_table, os.path.join(root, file), TMP,
PROJECT_TARGET_PATH) PROJECT_TARGET_PATH)
# safe_cpfile(compiled_file, PROJECT_TARGET_PATH, res_name) safe_cpfile(compiled_file, PROJECT_TARGET_PATH, res_name)
if __name__ == "__main__": if __name__ == "__main__":
...@@ -323,9 +352,11 @@ if __name__ == "__main__": ...@@ -323,9 +352,11 @@ if __name__ == "__main__":
print("-------------------------") print("-------------------------")
parser = argparse.ArgumentParser(description="Auto create Resource for ydl java project") parser = argparse.ArgumentParser(description="Auto create Resource for ydl java project")
parser.add_argument('--verbose', '-v', action='store_true', help='verbose mode') parser.add_argument('--verbose', '-v', action='store_true', help='debug mode')
parser.add_argument("resource_name") parser.add_argument("resource_name")
parser.add_argument("package")
parser.add_argument("project_path") parser.add_argument("project_path")
args = parser.parse_args() args = parser.parse_args()
project_path = args.project_path project_path = args.project_path
resource_name = args.resource_name resource_name = args.resource_name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment