Skip to content

Commit 1cb4457

Browse files
committed
I thout many --- were in msgstrs.
1 parent 53b8124 commit 1cb4457

3 files changed

Lines changed: 43 additions & 2 deletions

File tree

‎.scripts/replace.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
"""Search and replace in msgstrs."""
3+
4+
import sys
5+
from pathlib import Path
6+
7+
import polib
8+
9+
10+
def replace(file: Path, from_str: str, to_str: str) -> None:
11+
try:
12+
pofile = polib.pofile(file)
13+
except OSError:
14+
print(f"{file} doesn't seem to be a .po file", file=sys.stderr)
15+
return
16+
for entry in pofile:
17+
entry.msgstr = entry.msgstr.replace(from_str, to_str)
18+
pofile.save()
19+
20+
21+
def parse_args():
22+
import argparse
23+
24+
parser = argparse.ArgumentParser(description=__doc__)
25+
parser.add_argument("from_str", help="Replace occurrences of this string")
26+
parser.add_argument(
27+
"to_str",
28+
help="with this string.",
29+
)
30+
parser.add_argument("path", nargs="*", type=Path)
31+
return parser.parse_args()
32+
33+
34+
def main():
35+
args = parse_args()
36+
for filename in args.path:
37+
replace(filename, args.from_str, args.to_str)
38+
39+
40+
if __name__ == "__main__":
41+
main()

‎library/mailcap.po‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ msgstr ""
1616

1717
#: library/mailcap.rst:2
1818
msgid ":mod:`!mailcap` --- Mailcap file handling"
19-
msgstr ":mod:`!mailcap` --- Gestion des fichiers mailcap"
19+
msgstr ":mod:`!mailcap` — Gestion des fichiers mailcap"
2020

2121
#: library/mailcap.rst:10
2222
msgid ""

‎library/zipfile.po‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ msgid ""
380380
msgstr ""
381381
"*ZipFile* est aussi un gestionnaire de contexte et gère ainsi la "
382382
"déclaration :keyword:`with`. Dans l'exemple, *myzip* est fermé à la fin de "
383-
"la déclaration :keyword:`!with` --- même si une exception est levée ::"
383+
"la déclaration :keyword:`!with` — même si une exception est levée ::"
384384

385385
#: library/zipfile.rst:247
386386
msgid ""

0 commit comments

Comments
 (0)