FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-docs-pt-br/scripts/stats.py at migrate-shell-to-python · python/python-docs-pt-br · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python
/
python-docs-pt-br
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
41
Star
161
Code
Issues
13
Pull requests
4
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-pt-br
/
scripts
/
stats.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
55 lines (43 loc) · 1.61 KB
Breadcrumbs
python-docs-pt-br
/
scripts
/
stats.py
Copy path
File metadata and controls
executable file
·
55 lines (43 loc) · 1.61 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
#!/usr/bin/env python
"""
Obtain translation stats from the PO files directory and
store it with JSON format into 'stats.json'.
"""
import
json
import
os
import
logging
from
datetime
import
datetime
,
timezone
from
pathlib
import
Path
from
potodo
.
potodo
import
scan_path
logging
.
basicConfig
(
level
=
logging
.
INFO
)
def
main
()
->
None
:
"""Main function to generate translation stats."""
language
=
os
.
environ
.
get
(
"PYDOC_LANGUAGE"
)
if
not
language
:
raise
ValueError
(
"Environment variable PYDOC_LANGUAGE is not set."
)
pofiles_path
=
Path
(
f"cpython/Doc/locales/
{
language
}
/LC_MESSAGES"
)
if
not
pofiles_path
.
exists
():
raise
FileNotFoundError
(
f"Path does not exist:
{
pofiles_path
}
"
)
# Check for PO files inside the pofiles_path
if
not
list
(
pofiles_path
.
rglob
(
"*.po"
)):
raise
FileNotFoundError
(
f"No PO files found in
{
pofiles_path
}
"
)
stats
=
scan_path
(
pofiles_path
,
no_cache
=
True
,
hide_reserved
=
False
,
api_url
=
""
)
stats_data
=
{
"completion"
:
str
(
round
(
stats
.
completion
,
2
))
+
"%"
,
"translated"
:
stats
.
translated
,
"entries"
:
stats
.
entries
,
"updated_at"
:
datetime
.
now
(
timezone
.
utc
).
isoformat
(
timespec
=
"seconds"
)
+
"Z"
,
}
stats_json
=
pofiles_path
/
"stats.json"
try
:
with
stats_json
.
open
(
"w"
)
as
output_file
:
json
.
dump
(
stats_data
,
output_file
)
logging
.
info
(
f"Content written to
{
stats_json
}
"
)
except
IOError
as
e
:
logging
.
error
(
f"Failed to write to
{
stats_json
}
:
{
e
}
"
)
raise
if
__name__
==
"__main__"
:
try
:
main
()
except
Exception
as
e
:
logging
.
error
(
f"An error occurred:
{
e
}
"
)
Back
|
FazBrowse Home
|
New Git URL