FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
LeanType/tools/release.py at main · LeanBitLab/LeanType · GitHub
LeanBitLab
/
LeanType
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
56
Star
991
Code
Issues
61
Pull requests
4
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
LeanType
/
tools
/
release.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
158 lines (138 loc) · 6.03 KB
Breadcrumbs
LeanType
/
tools
/
release.py
Copy path
File metadata and controls
executable file
·
158 lines (138 loc) · 6.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/python
import
os
import
subprocess
import
sys
import
zipfile
from
urllib
.
request
import
urlretrieve
# git diff should be empty, and there should be no errors
def
check_git
():
result
=
subprocess
.
run
([
"git"
,
"diff"
,
"--name-only"
],
capture_output
=
True
)
if
result
.
returncode
!=
0
or
len
(
result
.
stdout
)
!=
0
:
cont
=
input
(
"uncommitted changes found, continue? [y/N] "
)
if
cont
!=
"y"
:
sys
.
exit
()
# download and update translations
def
update_translations
():
import
urllib
.
request
url
=
"https://translate.codeberg.org/download/heliboard/?format=zip"
zip_file_name
=
"translations.zip"
req
=
urllib
.
request
.
Request
(
url
,
headers
=
{
'Cookie'
:
'x-robot-challenge-2=passed'
})
with
urllib
.
request
.
urlopen
(
req
)
as
response
,
open
(
zip_file_name
,
'wb'
)
as
out_file
:
out_file
.
write
(
response
.
read
())
# extract all in heliboard/heliboard/app/src/main/res and heliboard/heliboard/fastlane/metadata
with
zipfile
.
ZipFile
(
zip_file_name
,
"r"
)
as
f
:
for
file
in
f
.
filelist
:
# We ONLY want the app/src/main/res translations, NOT fastlane/metadata (which contains Heliboard's titles & descriptions)
if
not
file
.
filename
.
startswith
(
"heliboard/heliboard/app/src/main/res"
):
continue
# Block extracting Heliboard's base string files, which would overwrite LeanType's English variants
if
file
.
filename
.
startswith
(
"heliboard/heliboard/app/src/main/res/values/"
):
continue
# Block extracting upstream release changelogs since LeanType tracks its own release cycle
if
"/changelogs/"
in
file
.
filename
:
continue
file
.
filename
=
file
.
filename
.
replace
(
"heliboard/heliboard/"
,
""
)
f
.
extract
(
file
)
os
.
remove
(
zip_file_name
)
# Replace "HeliBoard" with "LeanType" in all extracted translation files
# This ensures brand name consistency across all languages
import
re
for
root
,
dirs
,
files
in
os
.
walk
(
"app/src/main/res"
):
for
file
in
files
:
if
file
==
"strings.xml"
:
file_path
=
os
.
path
.
join
(
root
,
file
)
with
open
(
file_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
# Replace HeliBoard with LeanType (preserving case variations)
content
=
re
.
sub
(
r'HeliBoard'
,
'LeanType'
,
content
)
content
=
re
.
sub
(
r'Heliboard'
,
'LeanType'
,
content
)
with
open
(
file_path
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
content
)
# git diff to make sure default strings are the same
def
check_default_values_diff
():
result
=
subprocess
.
run
([
"git"
,
"diff"
,
"--name-only"
,
"app/src/main/res/values"
],
capture_output
=
True
)
if
result
.
returncode
!=
0
or
len
(
result
.
stdout
)
!=
0
:
raise
ValueError
(
"default strings changed after translation import, something is wrong"
)
def
read_dicts_readme
()
->
list
[
str
]:
dicts_readme_file
=
"../dictionaries/README.md"
if
os
.
path
.
isfile
(
dicts_readme_file
):
f
=
open
(
dicts_readme_file
)
lines
=
f
.
readlines
()
f
.
close
()
return
lines
readme_url
=
"https://codeberg.org/Helium314/aosp-dictionaries/raw/branch/main/README.md"
tmp_readme
=
"dicts_readme_tmp.md"
urlretrieve
(
readme_url
,
tmp_readme
)
f
=
open
(
tmp_readme
)
lines
=
f
.
readlines
()
f
.
close
()
os
.
remove
(
tmp_readme
)
return
lines
# generate a list of dictionaries available in the dictionaries repository at (https://codeberg.org/Helium314/aosp-dictionaries
# for convenient linking when adding dictionaries in HeliBoard.
def
update_dict_list
():
lines
=
read_dicts_readme
()
mode
=
0
dicts
=
[]
for
line
in
lines
:
line
=
line
.
strip
()
if
line
.
startswith
(
"#"
):
mode
=
0
if
line
.
startswith
(
"# Dictionaries"
):
mode
=
1
if
mode
==
0
or
not
line
.
startswith
(
"|"
)
or
line
.
startswith
(
"| Language |"
)
or
line
.
startswith
(
"| --- |"
):
continue
split
=
line
.
split
(
"|"
)
dict_name
=
split
[
2
].
split
(
"]"
)[
1
].
split
(
"("
)[
1
].
split
(
")"
)[
0
].
split
(
"/"
)[
-
1
].
split
(
".dict"
)[
0
]
(
dict_type
,
locale
)
=
dict_name
.
split
(
"_"
,
1
)
if
"_"
in
locale
:
sp
=
locale
.
split
(
"_"
)
locale
=
sp
[
0
]
for
s
in
sp
[
1
:]:
locale
=
locale
+
"_"
+
s
.
upper
()
if
split
[
3
].
strip
()
==
"yes"
:
extra
=
"exp"
elif
"UNICODE LICENSE V3 (CLDR)"
in
split
[
7
]:
extra
=
"cldr"
else
:
extra
=
""
dicts
.
append
(
f"
{
dict_type
}
,
{
locale
}
,
{
extra
}
\n
"
)
target_file
=
"app/src/main/assets/dictionaries_in_dict_repo.csv"
with
open
(
target_file
,
'w'
)
as
f
:
f
.
writelines
(
dicts
)
# check whether there is a changelog file for current version and print result and version code
def
check_changelog
():
changelog_dir
=
"fastlane/metadata/android/en-US/changelogs"
assert
os
.
path
.
isdir
(
changelog_dir
)
filenames
=
[]
for
file
in
os
.
scandir
(
changelog_dir
):
filenames
.
append
(
file
.
name
)
filenames
.
sort
()
changelog_version
=
filenames
[
-
1
].
replace
(
".txt"
,
""
)
version
=
""
with
open
(
"app/build.gradle.kts"
)
as
f
:
for
line
in
f
:
line
=
line
.
lstrip
()
if
line
.
startswith
(
"versionCode"
):
version
=
line
.
split
(
" "
)[
2
].
rstrip
()
break
if
changelog_version
==
version
:
print
(
"changelog for"
,
version
,
"exists"
)
else
:
print
(
"changelog for"
,
version
,
"does not exist"
)
# update khipro mapping json, see discussion at the bottom of https://github.com/Helium314/HeliBoard/pull/2134
def
update_khipro_mappings
():
source
=
"https://raw.githubusercontent.com/KhiproTeam/Khipro-Mappings/refs/heads/main/output/touchscreen.json"
target
=
"app/src/main/assets/khipro-mappings.json"
urlretrieve
(
source
,
target
)
def
main
():
if
os
.
getcwd
().
endswith
(
"tools"
):
os
.
chdir
(
"../"
)
check_git
()
update_translations
()
check_default_values_diff
()
update_dict_list
()
update_khipro_mappings
()
check_changelog
()
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL