Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
quick_generator
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lv xiang
quick_generator
Commits
7ee47f0a
Commit
7ee47f0a
authored
Jun 13, 2018
by
xxlv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix typo
parent
1b2386f8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
44 deletions
+82
-44
workspace.xml
.idea/workspace.xml
+41
-34
gen.py
gen.py
+41
-10
No files found.
.idea/workspace.xml
View file @
7ee47f0a
...
...
@@ -2,8 +2,6 @@
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<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"
/>
</list>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
...
...
@@ -18,11 +16,14 @@
</component>
<component
name=
"FileEditorManager"
>
<leaf
SIDE_TABS_SIZE_LIMIT_KEY=
"300"
>
<file
leaf-file-name=
"
.gitignore
"
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/
.gitignore
"
>
<file
leaf-file-name=
"
gen.py
"
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/
gen.py
"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<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"
/>
<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>
</provider>
</entry>
...
...
@@ -36,6 +37,7 @@
<find>
clean_tmp
</find>
<find>
gen_po
</find>
<find>
config_mybatis
</find>
<find>
compile_table
</find>
</findStrings>
<replaceStrings>
<replace>
${PLACE}
</replace>
...
...
@@ -53,8 +55,8 @@
<option
value=
"$PROJECT_DIR$/template/${PLACE}Biz.java"
/>
<option
value=
"$PROJECT_DIR$/heml.py"
/>
<option
value=
"$PROJECT_DIR$/tmp/generatorConfig.xml"
/>
<option
value=
"$PROJECT_DIR$/gen.py"
/>
<option
value=
"$PROJECT_DIR$/.gitignore"
/>
<option
value=
"$PROJECT_DIR$/gen.py"
/>
</list>
</option>
</component>
...
...
@@ -88,6 +90,11 @@
<item
name=
"quick_tpl"
type=
"b2602c69:ProjectViewProjectNode"
/>
<item
name=
"quick_tpl"
type=
"462c0819:PsiDirectoryNode"
/>
</path>
<path>
<item
name=
"quick_tpl"
type=
"b2602c69:ProjectViewProjectNode"
/>
<item
name=
"quick_tpl"
type=
"462c0819:PsiDirectoryNode"
/>
<item
name=
"template"
type=
"462c0819:PsiDirectoryNode"
/>
</path>
</expand>
<select
/>
</subPane>
...
...
@@ -208,8 +215,8 @@
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"7"
/>
<window_info
anchor=
"bottom"
id=
"Python Console"
order=
"9"
/>
<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"
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true
"
weight=
"0.25235197"
/>
<window_info
a
ctive=
"true"
a
nchor=
"bottom"
id=
"Terminal"
order=
"7"
visible=
"true"
weight=
"0.329718"
/>
<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=
"right"
id=
"Database"
order=
"3"
/>
<window_info
anchor=
"right"
id=
"SciView"
order=
"5"
/>
...
...
@@ -275,13 +282,6 @@
<option
name=
"myLimit"
value=
"2678400000"
/>
</component>
<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"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"165"
>
...
...
@@ -471,13 +471,6 @@
</state>
</provider>
</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"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
/>
</entry>
...
...
@@ -535,16 +528,6 @@
</state>
</provider>
</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"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"210"
>
...
...
@@ -555,7 +538,31 @@
<entry
file=
"file://$PROJECT_DIR$/.gitignore"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<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>
</provider>
</entry>
...
...
gen.py
View file @
7ee47f0a
...
...
@@ -195,11 +195,10 @@ def gen_po(res_name, project_target_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
)
gen_po_cmd
=
"""
java -jar {}/mybatis-generator-core-1.3.6.jar -configfile {} -overwrite
"""
.
format
(
JAR_PATH
,
local_mybatis_config_path
)
...
...
@@ -209,13 +208,12 @@ def gen_po(res_name, project_target_path):
print
(
"----------------------------------------"
)
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
()
return
po
# 编译内容
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
# 获取编译后的名字
def
compile
(
body
,
compile_table
):
"""
编译
:param body:
:param compile_table:
:return:
"""
for
d
,
v
in
compile_table
.
iteritems
():
body
=
body
.
replace
(
d
,
v
)
return
body
# clean tmp dir
def
clean_tmp
():
"""
清空临时目录
...
...
@@ -276,7 +279,6 @@ def clean_tmp():
print
(
"清空目录 {}"
.
format
(
TMP
))
# gen
def
gen
(
res_name
,
look_path
):
"""
核心逻辑
...
...
@@ -294,6 +296,8 @@ def gen(res_name, look_path):
PROJECT_TARGET_PATH
=
parse_ydl_project
(
look_path
)
print
(
PROJECT_TARGET_PATH
)
if
(
PROJECT_TARGET_PATH
):
print
(
"解析YDL Project 成功!"
)
else
:
...
...
@@ -303,17 +307,42 @@ def gen(res_name, look_path):
compile_table
=
dict
()
compile_table
[
'${PLACE}'
]
=
"{}{}"
.
format
(
res_name
[
0
]
.
upper
(),
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
(
"--------------------------------------"
)
# 编译文件
for
root
,
dirs
,
files
in
os
.
walk
(
DIR
,
False
):
for
file
in
files
:
if
(
file
[
0
]
==
"$"
):
compiled_file
=
compile_content
(
res_name
,
compile_table
,
os
.
path
.
join
(
root
,
file
),
TMP
,
PROJECT_TARGET_PATH
)
#
safe_cpfile(compiled_file, PROJECT_TARGET_PATH, res_name)
safe_cpfile
(
compiled_file
,
PROJECT_TARGET_PATH
,
res_name
)
if
__name__
==
"__main__"
:
...
...
@@ -323,9 +352,11 @@ if __name__ == "__main__":
print
(
"-------------------------"
)
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
(
"package"
)
parser
.
add_argument
(
"project_path"
)
args
=
parser
.
parse_args
()
project_path
=
args
.
project_path
resource_name
=
args
.
resource_name
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment