FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-docs-es/scripts/list_missing_entries.py at library_pathlib_3.13 · python/python-docs-es · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python
/
python-docs-es
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
412
Star
365
Code
Issues
423
Pull requests
17
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python-docs-es
/
scripts
/
list_missing_entries.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (44 loc) · 1.68 KB
Breadcrumbs
python-docs-es
/
scripts
/
list_missing_entries.py
Copy path
File metadata and controls
55 lines (44 loc) · 1.68 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
import
argparse
import
dataclasses
import
enum
import
glob
import
itertools
import
os
import
polib
import
tabulate
class
MissingReason
(
enum
.
StrEnum
):
FUZZY
=
"fuzzy"
UNTRANSLATED
=
"untranslated"
@
staticmethod
def
from_poentry
(
poentry
:
polib
.
POEntry
):
if
poentry
.
fuzzy
:
return
MissingReason
.
FUZZY
assert
not
poentry
.
translated
()
return
MissingReason
.
UNTRANSLATED
@
dataclasses
.
dataclass
class
MissingEntry
:
reason
:
MissingReason
file
:
str
line
:
int
@
staticmethod
def
from_poentry
(
pofilename
:
str
,
poentry
:
polib
.
POEntry
)
->
"MissingEntry"
:
return
MissingEntry
(
MissingReason
.
from_poentry
(
poentry
),
pofilename
,
poentry
.
linenum
)
def
find_missing_entries
(
filename
:
str
)
->
list
[
MissingEntry
]:
po
=
polib
.
pofile
(
filename
)
fuzzy
=
po
.
fuzzy_entries
()
untranslated
=
po
.
untranslated_entries
()
return
[
MissingEntry
.
from_poentry
(
filename
,
entry
)
for
entry
in
fuzzy
+
untranslated
]
def
main
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"files"
,
nargs
=
"+"
)
parser
.
add_argument
(
"-g"
,
"--github-mode"
,
help
=
"Produce output as a GitHub comment"
,
action
=
'store_true'
)
opts
=
parser
.
parse_args
()
missing_entries
=
list
(
itertools
.
chain
.
from_iterable
(
map
(
find_missing_entries
,
opts
.
files
)))
if
not
missing_entries
:
print
(
f"All entries translated, horray!
{
' :tada:'
if
opts
.
github_mode
else
''
}
"
)
else
:
missing_entries
.
sort
(
key
=
lambda
entry
: (
entry
.
file
,
entry
.
line
))
print
(
"Entries missing translation, details follow:
\n
"
)
print
(
tabulate
.
tabulate
(
missing_entries
,
headers
=
[
"Reason"
,
"File"
,
"Line"
],
tablefmt
=
"github"
))
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL