Remove translation stub functions

Fixes: https://pagure.io/koji/issue/3072
This commit is contained in:
Jana Cupova 2021-10-18 21:52:15 +02:00
parent 9e542f509a
commit 32b5377392
11 changed files with 1403 additions and 1556 deletions

View file

@ -40,7 +40,7 @@ import koji
import koji.plugin
import koji.util
from koji_cli.commands import * # noqa: F401, F403
from koji_cli.lib import _, categories, get_epilog_str, greetings, warn
from koji_cli.lib import categories, get_epilog_str, greetings, warn
def register_plugin(plugin):
@ -105,8 +105,8 @@ def get_options():
common_commands = ['build', 'help', 'download-build',
'latest-build', 'search', 'list-targets']
usage = _("%%prog [global-options] command [command-options-and-arguments]"
"\n\nCommon commands: %s" % ', '.join(sorted(common_commands)))
usage = "%%prog [global-options] command [command-options-and-arguments]\n\n" \
"Common commands: %s" % ', '.join(sorted(common_commands))
parser = OptionParser(usage=usage)
parser.disable_interspersed_args()
progname = os.path.basename(sys.argv[0]) or 'koji'
@ -116,38 +116,33 @@ def get_options():
'origin_format_help': parser.origin_format_help(formatter),
'epilog': get_epilog_str()}))
parser.add_option("-p", "--profile", default=progname,
help=_("specify a configuration profile. default: %s" % progname))
help="specify a configuration profile. default: %s" % progname)
parser.add_option("-c", "--config", dest="configFile",
help=_("load profile's settings from another file"), metavar="FILE")
parser.add_option("--keytab", help=_("specify a Kerberos keytab to use"), metavar="FILE")
parser.add_option("--principal", help=_("specify a Kerberos principal to use"))
parser.add_option("--cert", help=_("specify a SSL cert to use"), metavar="FILE")
parser.add_option("--runas", help=_("run as the specified user (requires special privileges)"))
parser.add_option("--user", help=_("specify user"))
parser.add_option("--password", help=_("specify password"))
parser.add_option("--noauth", action="store_true", default=False,
help=_("do not authenticate"))
help="load profile's settings from another file", metavar="FILE")
parser.add_option("--keytab", help="specify a Kerberos keytab to use", metavar="FILE")
parser.add_option("--principal", help="specify a Kerberos principal to use")
parser.add_option("--cert", help="specify a SSL cert to use", metavar="FILE")
parser.add_option("--runas", help="run as the specified user (requires special privileges)")
parser.add_option("--user", help="specify user")
parser.add_option("--password", help="specify password")
parser.add_option("--noauth", action="store_true", default=False, help="do not authenticate")
parser.add_option("--force-auth", action="store_true", # default (False) comes from the config
help=_("authenticate even for read-only operations"))
parser.add_option("--authtype", help=_("force use of a type of authentication, options: "
"noauth, ssl, password, or kerberos"))
parser.add_option("-d", "--debug", action="store_true",
help=_("show debug output"))
parser.add_option("--debug-xmlrpc", action="store_true",
help=_("show xmlrpc debug output"))
parser.add_option("-q", "--quiet", action="store_true", default=False,
help=_("run quietly"))
help="authenticate even for read-only operations")
parser.add_option("--authtype", help="force use of a type of authentication, options: "
"noauth, ssl, password, or kerberos")
parser.add_option("-d", "--debug", action="store_true", help="show debug output")
parser.add_option("--debug-xmlrpc", action="store_true", help="show xmlrpc debug output")
parser.add_option("-q", "--quiet", action="store_true", default=False, help="run quietly")
parser.add_option("--skip-main", action="store_true", default=False,
help=_("don't actually run main"))
parser.add_option("-s", "--server", help=_("url of XMLRPC server"))
parser.add_option("--topdir", help=_("specify topdir"))
parser.add_option("--weburl", help=_("url of the Koji web interface"))
parser.add_option("--topurl", help=_("url for Koji file access"))
help="don't actually run main")
parser.add_option("-s", "--server", help="url of XMLRPC server")
parser.add_option("--topdir", help="specify topdir")
parser.add_option("--weburl", help="url of the Koji web interface")
parser.add_option("--topurl", help="url for Koji file access")
parser.add_option("--pkgurl", help=SUPPRESS_HELP)
parser.add_option("--plugin-paths", metavar='PATHS',
help=_("specify additional plugin paths (colon separated)"))
parser.add_option("--help-commands", action="store_true", default=False,
help=_("list commands"))
help="specify additional plugin paths (colon separated)")
parser.add_option("--help-commands", action="store_true", default=False, help="list commands")
(options, args) = parser.parse_args()
# load local config
@ -227,8 +222,8 @@ def get_options():
def handle_help(options, session, args):
"[info] List available commands"
usage = _("usage: %prog help <category> ...")
usage += _("\n(Specify the --help global option for a list of other help options)")
usage = "usage: %prog help <category> ..."
usage += "\n(Specify the --help global option for a list of other help options)"
parser = OptionParser(usage=usage)
# the --admin opt is for backwards compatibility. It is equivalent to: koji help admin
parser.add_option("--admin", action="store_true", help=SUPPRESS_HELP)
@ -290,9 +285,9 @@ def list_commands(categories_chosen=None):
alias = alias.replace('_', '-')
handlers.append((alias, value))
handlers.sort()
print(_("Available commands:"))
print("Available commands:")
for category in categories_chosen:
print(_("\n%s:" % categories[category]))
print("\n%s:" % categories[category])
for alias, handler in handlers:
desc = handler.__doc__ or ''
if desc.startswith('[%s] ' % category):

File diff suppressed because it is too large Load diff

View file

@ -21,6 +21,7 @@ from six.moves import range
import koji
# import parse_arches to current namespace for backward compatibility
from koji import parse_arches
from koji import _ # noqa: F401
from koji.util import md5_constructor, to_list
from koji.xmlrpcplus import xmlrpc_client
@ -43,8 +44,7 @@ def _check_time_option(option, opt, value):
ts = time.mktime(dt.timetuple())
return ts
except Exception:
raise optparse.OptionValueError(
_("option %s: invalid time specification: %r") % (opt, value))
raise optparse.OptionValueError("option %s: invalid time specification: %r" % (opt, value))
class TimeOption(optparse.Option):
@ -55,9 +55,8 @@ class TimeOption(optparse.Option):
@classmethod
def get_help(self):
return _("time is specified as timestamp or date/time in any "
"format which can be parsed by dateutil.parser. e.g. "
"\"2020-12-31 12:35\" or \"December 31st 12:35\"")
return "time is specified as timestamp or date/time in any format which can be " \
"parsed by dateutil.parser. e.g. \"2020-12-31 12:35\" or \"December 31st 12:35\""
greetings = ('hello', 'hi', 'yo', "what's up", "g'day", 'back to work',
@ -87,11 +86,6 @@ ARGMAP = {'None': None,
'False': False}
def _(args):
"""Stub function for translation"""
return args
def arg_filter(arg):
try:
return int(arg)
@ -130,11 +124,11 @@ Try "%(progname)s <command> --help" for help about the options of a particular c
Try "%(progname)s help <category>" to get commands under a particular category
Available categories are: %(categories)s
''' % ({'progname': progname, 'categories': categories_ordered})
return _(epilog_str)
return epilog_str
def get_usage_str(usage):
return usage + _("\n(Specify the --help global option for a list of other help options)")
return usage + "\n(Specify the --help global option for a list of other help options)"
def ensure_connection(session, options=None):
@ -145,14 +139,14 @@ def ensure_connection(session, options=None):
try:
ret = session.getAPIVersion()
except requests.exceptions.ConnectionError as ex:
warn(_("Error: Unable to connect to server"))
warn("Error: Unable to connect to server")
if options and getattr(options, 'debug', False):
error(str(ex))
else:
error()
if ret != koji.API_VERSION:
warn(_("WARNING: The server is at API version %d and "
"the client is at %d" % (ret, koji.API_VERSION)))
warn("WARNING: The server is at API version %d and "
"the client is at %d" % (ret, koji.API_VERSION))
def print_task_headers():
@ -565,9 +559,9 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None,
koji.ensuredir(os.path.dirname(relpath))
if not quiet:
if size and num:
print(_("Downloading [%d/%d]: %s") % (num, size, relpath))
print("Downloading [%d/%d]: %s" % (num, size, relpath))
else:
print(_("Downloading: %s") % relpath)
print("Downloading: %s" % relpath)
pos = 0
headers = {}
@ -578,10 +572,10 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None,
if pos:
if filesize == pos:
if not quiet:
print(_("File %s already downloaded, skipping" % relpath))
print("File %s already downloaded, skipping" % relpath)
return
if not quiet:
print(_("Appending to existing file %s" % relpath))
print("Appending to existing file %s" % relpath)
headers['Range'] = ('bytes=%d-' % pos)
else:
# rewrite
@ -754,9 +748,9 @@ def activate_session(session, options):
else:
session.gssapi_login(proxyuser=runas)
except socket.error as e:
warn(_("Could not connect to Kerberos authentication service: %s") % e.args[1])
warn("Could not connect to Kerberos authentication service: %s" % e.args[1])
if not noauth and not session.logged_in:
error(_("Unable to log in, no authentication methods available"))
error("Unable to log in, no authentication methods available")
# don't add "options" to ensure_connection it would create loop in case of --force-auth
# when it calls activate_session
ensure_connection(session)