File tree 1 file changed +18
-7
lines changed
1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 1
- # /// script
2
- # dependencies = [
3
- # "polib",
4
- # ]
5
- # ///
1
+ """
2
+ A utility script to extract message IDs from PO files.
3
+
4
+ This script extracts a specific message ID from a PO file based on the file name
5
+ and occurrence number. It's useful for retrieving translation strings for
6
+ specific occurrences in the Python documentation.
7
+
8
+ Usage:
9
+ python intercept.py path/to/file.po [-n OCCURRENCE_NUMBER]
10
+
11
+ Arguments:
12
+ path: Path to a PO file
13
+ -n, --occurrence_number: The occurrence number to match (default: 1)
14
+ """
6
15
import argparse
7
16
from pathlib import Path
8
17
@@ -24,11 +33,13 @@ def get_pofile_from_path(path: Path) -> polib.POFile:
24
33
25
34
26
35
if __name__ == '__main__' :
27
- parser = argparse .ArgumentParser ()
36
+ parser = argparse .ArgumentParser (
37
+ description = "Extract message IDs from PO files"
38
+ )
28
39
parser .add_argument ("path" , type = Path ,
29
40
help = "the path of a PO file" )
30
41
parser .add_argument ("-n" , '--occurrence_number' ,
31
- type = int , default = 1 )
42
+ type = int , default = 1 , help = "the occurrence number to match" )
32
43
args = parser .parse_args ()
33
44
path = args .path .resolve ()
34
45
pofile = get_pofile_from_path (path )
You can’t perform that action at this time.
0 commit comments