aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/gettext.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-09-09 10:31:52 -0700
committerGitHub <noreply@github.com>2020-09-09 10:31:52 -0700
commit4c2d0eb9bcedefa3ef06a237a0502afbc581268b (patch)
tree1b08ca5fb0c93573409a7a8954e6e1905f8a5b10 /mesonbuild/scripts/gettext.py
parent8d54b7bda30062569c981b50a85a175565a7c15a (diff)
parent057c77f7d08b3372e99065fb3f3cd37f16801a82 (diff)
downloadmeson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.zip
meson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.tar.gz
meson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.tar.bz2
Merge pull request #7657 from mensinda/moreTyping
typing: Strict type annotations
Diffstat (limited to 'mesonbuild/scripts/gettext.py')
-rw-r--r--mesonbuild/scripts/gettext.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py
index 7042863..547d14f 100644
--- a/mesonbuild/scripts/gettext.py
+++ b/mesonbuild/scripts/gettext.py
@@ -17,6 +17,7 @@ import shutil
import argparse
import subprocess
from . import destdir_join
+import typing as T
parser = argparse.ArgumentParser()
parser.add_argument('command')
@@ -27,7 +28,7 @@ parser.add_argument('--localedir', default='')
parser.add_argument('--subdir', default='')
parser.add_argument('--extra-args', default='')
-def read_linguas(src_sub):
+def read_linguas(src_sub: str) -> T.List[str]:
# Syntax of this file is documented here:
# https://www.gnu.org/software/gettext/manual/html_node/po_002fLINGUAS.html
linguas = os.path.join(src_sub, 'LINGUAS')
@@ -43,7 +44,7 @@ def read_linguas(src_sub):
print('Could not find file LINGUAS in {}'.format(src_sub))
return []
-def run_potgen(src_sub, pkgname, datadirs, args):
+def run_potgen(src_sub: str, pkgname: str, datadirs: str, args: T.List[str]) -> int:
listfile = os.path.join(src_sub, 'POTFILES.in')
if not os.path.exists(listfile):
listfile = os.path.join(src_sub, 'POTFILES')
@@ -60,13 +61,13 @@ def run_potgen(src_sub, pkgname, datadirs, args):
'-D', os.environ['MESON_SOURCE_ROOT'], '-k_', '-o', ofile] + args,
env=child_env)
-def gen_gmo(src_sub, bld_sub, langs):
+def gen_gmo(src_sub: str, bld_sub: str, langs: T.List[str]) -> int:
for l in langs:
subprocess.check_call(['msgfmt', os.path.join(src_sub, l + '.po'),
'-o', os.path.join(bld_sub, l + '.gmo')])
return 0
-def update_po(src_sub, pkgname, langs):
+def update_po(src_sub: str, pkgname: str, langs: T.List[str]) -> int:
potfile = os.path.join(src_sub, pkgname + '.pot')
for l in langs:
pofile = os.path.join(src_sub, l + '.po')
@@ -76,7 +77,7 @@ def update_po(src_sub, pkgname, langs):
subprocess.check_call(['msginit', '--input', potfile, '--output-file', pofile, '--locale', l, '--no-translator'])
return 0
-def do_install(src_sub, bld_sub, dest, pkgname, langs):
+def do_install(src_sub: str, bld_sub: str, dest: str, pkgname: str, langs: T.List[str]) -> int:
for l in langs:
srcfile = os.path.join(bld_sub, l + '.gmo')
outfile = os.path.join(dest, l, 'LC_MESSAGES',
@@ -88,7 +89,7 @@ def do_install(src_sub, bld_sub, dest, pkgname, langs):
print('Installing %s to %s' % (srcfile, outfile))
return 0
-def run(args):
+def run(args: T.List[str]) -> int:
options = parser.parse_args(args)
subcmd = options.command
langs = options.langs.split('@@') if options.langs else None
@@ -120,3 +121,4 @@ def run(args):
else:
print('Unknown subcommand.')
return 1
+ return 0