Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Adam <dev@robert-adam.de>2022-08-26 19:17:56 +0300
committerRobert Adam <dev@robert-adam.de>2022-09-10 18:10:14 +0300
commit42e6377c25f0b31cb147d7d69ba0ebc263acfc6d (patch)
treeb75d8c383bd8939edc213e1a7065cb6232327a61 /scripts
parent9eb33c6f581f094cfe291ab77b735c7b2bc2bf4e (diff)
MAINT: Update generate-mumble_qt-qrc.py
Adapted script to work with Python3 and to use proper argument parsing
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate-mumble_qt-qrc.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/scripts/generate-mumble_qt-qrc.py b/scripts/generate-mumble_qt-qrc.py
index c62b1095e..837ed498d 100755
--- a/scripts/generate-mumble_qt-qrc.py
+++ b/scripts/generate-mumble_qt-qrc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright 2015-2022 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
@@ -7,6 +7,7 @@
from __future__ import (unicode_literals, print_function, division)
+import argparse
import os
import platform
import sys
@@ -41,7 +42,7 @@ def parseTranslationsConfig(configFile):
# Replace the trailing .ts with .qm as this is what lrelease will turn it into
translationFileName = translationFileName[:-3] + ".qm"
-
+
local_qt_translations.append(translationFileName)
if operator == "fallback":
@@ -67,7 +68,7 @@ def getComponentName(fileName):
lastUnderscoreIdx = component.rfind('_')
component = fileName[:lastUnderscoreIdx]
lang = fileName[lastUnderscoreIdx+1:]
-
+
return component
@@ -95,7 +96,7 @@ def filesToQrc(outFile, processedComponents, fileNames, directoryPath, localTran
if not component in allowed_components:
continue
-
+
if name in processedComponents and not isOverride:
continue
@@ -115,26 +116,27 @@ def filesToQrc(outFile, processedComponents, fileNames, directoryPath, localTran
def main():
# python generate-mumble_qt-qrc.py <output-fn> [inputs...] localDir
- output = sys.argv[1]
- inputs = sys.argv[2:-1]
- localDir = sys.argv[-1]
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--output", help="The path to which to write the generated QRC file", metavar="PATH", required=True)
+ parser.add_argument("--translation-dir", help="The path to the directory containing the official Qt translations",
+ action="append", metavar="PATH", required=True)
+ parser.add_argument("--local-translation-dir", help="The path to the local translation directory", metavar="PATH", required=True)
- # parse config file
- if localDir.endswith("/") or localDir.endswith("\\"):
- localDir = localDir[:-1]
+ args = parser.parse_args()
- configFile = os.path.join(localDir, "translations.conf")
+ # parse config file
+ configFile = os.path.join(args.local_translation_dir, "translations.conf")
if os.path.isfile(configFile):
parseTranslationsConfig(configFile)
- of = open(output, 'w')
+ of = open(args.output, 'w')
of.write('<!DOCTYPE RCC><RCC version="1.0">\n')
of.write('<qresource>\n')
processedComponents = []
- for dirName in inputs:
+ for dirName in args.translation_dir:
processedComponents.extend(dirToQrc(of, dirName, processedComponents))
# Process translations provided by Mumble itself (aka local translations)
- filesToQrc(of, processedComponents, local_qt_translations, localDir, True)
+ filesToQrc(of, processedComponents, local_qt_translations, args.local_translation_dir, True)
of.write('</qresource>\n')
of.write('</RCC>\n')
of.close()