Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
config_repository
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
config_repository
Commits
d9cfbc6e
Commit
d9cfbc6e
authored
Nov 15, 2018
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加yaml文件
parent
3e672e71
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
0 deletions
+97
-0
settings.json
.vscode/settings.json
+3
-0
replace.py
yaml/replace.py
+60
-0
replace_config.yaml
yaml/replace_config.yaml
+34
-0
No files found.
.vscode/settings.json
0 → 100644
View file @
d9cfbc6e
{
"python.linting.pylintEnabled"
:
false
}
\ No newline at end of file
yaml/replace.py
0 → 100644
View file @
d9cfbc6e
# coding=UTF-8
from
__future__
import
print_function
import
io
import
yaml
import
fileinput
import
os
import
os.path
import
re
import
copy
f
=
io
.
open
(
'replace_config.yaml'
,
'r'
,
encoding
=
'utf-8'
)
res
=
yaml
.
load
(
f
)
print
(
"全部配置信息:"
,
res
)
# 查看配置中是否有当前项目
env
=
os
.
environ
project
=
env
.
get
(
'SYSTEM_NAME'
)
distPath
=
os
.
path
.
abspath
(
project
+
'/dist'
)
config
=
res
.
get
(
project
,
res
.
get
(
'common'
))
print
(
project
,
"的配置信息:"
,
config
)
print
(
"dist路径:"
,
distPath
)
# 根据内容进行替换
namespace
=
env
.
get
(
'NAMESPACE'
)
print
(
'namespace:'
,
namespace
)
files
=
[]
acceptType
=
{
'.html'
,
'.js'
,
'.css'
}
def
findFile
(
dir
):
if
os
.
path
.
isfile
(
dir
):
suffix
=
os
.
path
.
splitext
(
dir
)[
-
1
]
if
(
suffix
in
acceptType
):
files
.
append
(
dir
)
return
else
:
for
sub
in
os
.
listdir
(
dir
):
findFile
(
dir
+
'/'
+
sub
)
# 过滤符合要求的文件路径
findFile
(
distPath
)
# 替换文件中的内容
for
file
in
files
:
for
line
in
fileinput
.
input
(
file
,
inplace
=
1
):
for
item
in
config
:
if
not
config
[
item
]:
continue
rule
=
copy
.
deepcopy
(
config
[
item
])
if
rule
.
get
(
'useNamespace'
,
None
)
and
rule
[
'to'
]:
rule
[
'to'
]
=
'-'
+
namespace
+
rule
[
'to'
]
if
rule
[
'reg'
]:
p
=
re
.
compile
(
r''
+
rule
[
'reg'
])
line
=
re
.
sub
(
p
,
rule
[
'to'
],
line
)
print
(
line
,
end
=
''
)
fileinput
.
close
()
f
.
close
()
\ No newline at end of file
yaml/replace_config.yaml
0 → 100644
View file @
d9cfbc6e
# reg: 匹配的正则
# to: 正则匹配后替换需要的值
# useNamespace: 是否在替换的值前追加 '-[namespace名称]'
lkbDomain
:
&lkbDomain
'
.liangkebang.com'
# 替换xyqbapi
xyqbApiRule
:
&xyqbApiRule
reg
:
'
(?<=\w).xyqb.com'
to
:
*lkbDomain
useNamespace
:
true
# 替换cookie,需要放在api规则后;或者需要改正则
xyqbCookieRule
:
&xyqbCookieRule
reg
:
'
.xyqb.com'
to
:
*lkbDomain
qgApiRule
:
&qgApiRule
reg
:
'
(?<=\w).q-gp.com'
to
:
*lkbDomain
useNamespace
:
true
# todo: 看哪个项目需要
h5AuthRule
:
&h5AuthRule
reg
:
'
h5.auth.quantgroup.cn'
to
:
'
operator.liangkebang.com'
# todo: quantgroup.cn
common
:
&common
xyqbApiRule
:
*xyqbApiRule
qgApiRule
:
*qgApiRule
xyqbCookieRule
:
*xyqbCookieRule
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