Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
Scan QR Code Barcode Reader
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Scan QR Code Barcode Reader
Commits
f1c736a2
Commit
f1c736a2
authored
Dec 31, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...新脚本
parent
128338fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
GetInfo.py
app/GetInfo.py
+4
-4
No files found.
app/GetInfo.py
View file @
f1c736a2
...
@@ -83,23 +83,23 @@ def update_global_config(file_path, json_data):
...
@@ -83,23 +83,23 @@ def update_global_config(file_path, json_data):
# 遍历 JSON 数据中的每个变量名,并在 GlobalConfig.kt 中更新对应的值
# 遍历 JSON 数据中的每个变量名,并在 GlobalConfig.kt 中更新对应的值
for
var_name
,
var_value
in
json_data
.
items
():
for
var_name
,
var_value
in
json_data
.
items
():
# 替换 const val 的值
# 替换 const val 的值
pattern_const
=
rf
'
\b
const
\
s+val
\
s+{re.escape(var_name)}
\
s*=
\
s*
".*?"
'
pattern_const
=
rf
'
\b
const
\
s+val
\
s+{re.escape(var_name)}
\
s*=
\
s*
.*
'
replacement_const
=
f
'const val {var_name} = "{var_value}"'
replacement_const
=
f
'const val {var_name} = "{var_value}"'
content
=
re
.
sub
(
pattern_const
,
replacement_const
,
content
)
content
=
re
.
sub
(
pattern_const
,
replacement_const
,
content
)
# 替换 inline val 的值
pattern_inline
=
rf
'
\b
inline
\
s+val
\
s+{re.escape(var_name)}
\
s+get
\
(
\
)
\
s*=
\
s*.*'
pattern_inline
=
rf
'
\b
inline
\
s+val
\
s+{re.escape(var_name)}
\
s+get
\
(
\
)
\
s*=
\
s*".*?"'
replacement_inline
=
f
'inline val {var_name} get() = "{var_value}"'
replacement_inline
=
f
'inline val {var_name} get() = "{var_value}"'
content
=
re
.
sub
(
pattern_inline
,
replacement_inline
,
content
)
content
=
re
.
sub
(
pattern_inline
,
replacement_inline
,
content
)
# 将修改后的内容写回到 GlobalConfig.kt 文件
# 将修改后的内容写回到 GlobalConfig.kt 文件
with
open
(
file_path
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
with
open
(
file_path
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
file
.
write
(
content
)
file
.
write
(
content
)
print
(
content
)
print
(
"
\n
GlobalConfig.kt 文件已成功更新。"
)
print
(
"
\n
GlobalConfig.kt 文件已成功更新。"
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"更新文件时发生错误: {e}"
)
print
(
f
"更新文件时发生错误: {e}"
)
def
update_google_services
(
json_data
):
def
update_google_services
(
json_data
):
"""更新 google-services.json 文件内容"""
"""更新 google-services.json 文件内容"""
try
:
try
:
...
...
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