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+ """
615import argparse
716from pathlib import Path
817
@@ -24,11 +33,13 @@ def get_pofile_from_path(path: Path) -> polib.POFile:
2433
2534
2635if __name__ == '__main__' :
27- parser = argparse .ArgumentParser ()
36+ parser = argparse .ArgumentParser (
37+ description = "Extract message IDs from PO files"
38+ )
2839parser .add_argument ("path" ,type = Path ,
2940help = "the path of a PO file" )
3041parser .add_argument ("-n" ,'--occurrence_number' ,
31- type = int ,default = 1 )
42+ type = int ,default = 1 , help = "the occurrence number to match" )
3243args = parser .parse_args ()
3344path = args .path .resolve ()
3445pofile = get_pofile_from_path (path )