FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-docs-zh-cn/.github/scripts/tx_stat.py at master · python/python-docs-zh-cn · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python
/
python-docs-zh-cn
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
103
Star
466
Code
Issues
5
Pull requests
3
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-docs-zh-cn
/
.github
/
scripts
/
tx_stat.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (26 loc) · 991 Bytes
Breadcrumbs
python-docs-zh-cn
/
.github
/
scripts
/
tx_stat.py
Copy path
File metadata and controls
33 lines (26 loc) · 991 Bytes
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
import
json
import
os
import
urllib
.
request
from
datetime
import
datetime
key
=
os
.
environ
.
get
(
'TX_TOKEN'
)
project
=
os
.
environ
.
get
(
'TX_PROJECT'
)
url
=
"https://rest.api.transifex.com/resource_language_stats?filter[project]=o%3Apython-doc%3Ap%3A{}&filter[language]=l%3Azh_CN"
.
format
(
project
)
headers
=
{
"accept"
:
"application/vnd.api+json"
,
"authorization"
:
"Bearer "
+
key
}
total
=
0
translated
=
0
while
(
url
):
request
=
urllib
.
request
.
Request
(
url
=
url
,
headers
=
headers
)
with
urllib
.
request
.
urlopen
(
request
)
as
response
:
data
=
json
.
loads
(
response
.
read
().
decode
(
"utf-8"
))
url
=
data
[
'links'
].
get
(
'next'
)
for
resourse
in
data
[
'data'
]:
translated
=
translated
+
resourse
[
'attributes'
][
'translated_strings'
]
total
=
total
+
resourse
[
'attributes'
][
'total_strings'
]
p
=
'{:.2%}'
.
format
(
translated
/
total
)
print
(
json
.
dumps
({
'translation'
:
p
,
'updated_at'
:
datetime
.
utcnow
().
isoformat
(
timespec
=
'seconds'
)
+
'Z'
,
}))
Back
|
FazBrowse Home
|
New Git URL