Add some type annotations to main in qlocalexml2cpp.py
Task-number: QTBUG-128634 Pick-to: 6.8 Change-Id: Iaf5a25da86dd330bdab893b34c7c1288e239a182 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
a9a5f86a8b
commit
cd6491e950
@ -17,7 +17,7 @@ The ISO 639-3 data file can be downloaded from the SIL website:
|
|||||||
import datetime
|
import datetime
|
||||||
import argparse
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable, Iterator, Optional
|
from typing import AnyStr, Callable, Iterator, Optional, TextIO
|
||||||
|
|
||||||
from qlocalexml import Locale, QLocaleXmlReader
|
from qlocalexml import Locale, QLocaleXmlReader
|
||||||
from localetools import *
|
from localetools import *
|
||||||
@ -970,7 +970,7 @@ class LocaleHeaderWriter (SourceFileEditor):
|
|||||||
out('\n };\n')
|
out('\n };\n')
|
||||||
|
|
||||||
|
|
||||||
def main(argv, out, err):
|
def main(argv: list[str], out: TextIO, err: TextIO) -> int:
|
||||||
"""Updates QLocale's CLDR data from a QLocaleXML file.
|
"""Updates QLocale's CLDR data from a QLocaleXML file.
|
||||||
|
|
||||||
Takes sys.argv, sys.stdout, sys.stderr (or equivalents) as
|
Takes sys.argv, sys.stdout, sys.stderr (or equivalents) as
|
||||||
@ -983,7 +983,7 @@ def main(argv, out, err):
|
|||||||
|
|
||||||
Updates various src/corelib/t*/q*_data_p.h files within the qtbase
|
Updates various src/corelib/t*/q*_data_p.h files within the qtbase
|
||||||
checkout to contain data extracted from the QLocaleXML file."""
|
checkout to contain data extracted from the QLocaleXML file."""
|
||||||
calendars_map = {
|
calendars_map: dict[str, str] = {
|
||||||
# CLDR name: Qt file name fragment
|
# CLDR name: Qt file name fragment
|
||||||
'gregorian': 'roman',
|
'gregorian': 'roman',
|
||||||
'persian': 'jalali',
|
'persian': 'jalali',
|
||||||
@ -1008,12 +1008,12 @@ def main(argv, out, err):
|
|||||||
action='count', default=0)
|
action='count', default=0)
|
||||||
parser.add_argument('-q', '--quiet', help='less output',
|
parser.add_argument('-q', '--quiet', help='less output',
|
||||||
dest='verbose', action='store_const', const=-1)
|
dest='verbose', action='store_const', const=-1)
|
||||||
args = parser.parse_args(argv[1:])
|
args: argparse.Namespace = parser.parse_args(argv[1:])
|
||||||
mutter = (lambda *x: None) if args.verbose < 0 else out.write
|
mutter: Callable[[AnyStr], int] = (lambda *x: 0) if args.verbose < 0 else out.write
|
||||||
|
|
||||||
qlocalexml = args.input_file
|
qlocalexml: str = args.input_file
|
||||||
qtsrcdir = Path(args.qtbase_path)
|
qtsrcdir = Path(args.qtbase_path)
|
||||||
calendars = {cal: calendars_map[cal] for cal in args.calendars}
|
calendars: dict[str, str] = {cal: calendars_map[cal] for cal in args.calendars}
|
||||||
|
|
||||||
if not (qtsrcdir.is_dir()
|
if not (qtsrcdir.is_dir()
|
||||||
and all(qtsrcdir.joinpath('src/corelib/text', leaf).is_file()
|
and all(qtsrcdir.joinpath('src/corelib/text', leaf).is_file()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user