Add some type annotations to main in qlocalexml2cpp.py
Task-number: QTBUG-128634 Change-Id: Iaf5a25da86dd330bdab893b34c7c1288e239a182 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit cd6491e9500dc6e0ebe6a39ea791e3c643223a62)
This commit is contained in:
parent
582eaaaa68
commit
20ccdf05a7
@ -17,7 +17,7 @@ The ISO 639-3 data file can be downloaded from the SIL website:
|
||||
import datetime
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
from typing import Callable, Iterator, Optional
|
||||
from typing import Callable, Iterator, Optional, TextIO
|
||||
|
||||
from qlocalexml import Locale, QLocaleXmlReader
|
||||
from localetools import *
|
||||
@ -666,7 +666,7 @@ class LocaleHeaderWriter (SourceFileEditor):
|
||||
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.
|
||||
|
||||
Takes sys.argv, sys.stdout, sys.stderr (or equivalents) as
|
||||
@ -679,7 +679,7 @@ def main(argv, out, err):
|
||||
|
||||
Updates various src/corelib/t*/q*_data_p.h files within the qtbase
|
||||
checkout to contain data extracted from the QLocaleXML file."""
|
||||
calendars_map = {
|
||||
calendars_map: dict[str, str] = {
|
||||
# CLDR name: Qt file name fragment
|
||||
'gregorian': 'roman',
|
||||
'persian': 'jalali',
|
||||
@ -700,11 +700,11 @@ def main(argv, out, err):
|
||||
parser.add_argument('--calendars', help='select calendars to emit data for',
|
||||
nargs='+', metavar='CALENDAR',
|
||||
choices=all_calendars, default=all_calendars)
|
||||
args = parser.parse_args(argv[1:])
|
||||
args: argparse.Namespace = parser.parse_args(argv[1:])
|
||||
|
||||
qlocalexml = args.input_file
|
||||
qlocalexml: str = args.input_file
|
||||
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()
|
||||
and all(qtsrcdir.joinpath('src/corelib/text', leaf).is_file()
|
||||
|
Loading…
x
Reference in New Issue
Block a user