Make changes to use gettext() function correctly.

This commit is contained in:
Aditya Toshniwal 2020-04-15 15:30:33 +05:30 committed by Akshay Joshi
parent 0424f7d962
commit 31a929388b
31 changed files with 76 additions and 52 deletions

View File

@ -503,7 +503,7 @@ def create_app(app_name=None):
svr_discovery_id = inst_id
svr_comment = gettext(
"Auto-detected %s installation with the data "
"directory at %s") % (
"directory at {}").format(
winreg.QueryValueEx(
inst_key, 'Display Name'
)[0],
@ -557,11 +557,9 @@ def create_app(app_name=None):
if hasattr(str, 'decode'):
description = description.decode('utf-8')
data_directory = data_directory.decode('utf-8')
svr_comment = gettext(u"Auto-detected %s installation "
u"with the data directory at %s") % (
description,
data_directory
)
svr_comment = gettext(u"Auto-detected {0} installation "
u"with the data directory at {1}"
).format(description, data_directory)
add_server(user_id, servergroup_id, svr_name,
svr_superuser, svr_port, svr_discovery_id,
svr_comment)

View File

@ -737,7 +737,8 @@ class ServerNode(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
if 'hostaddr' in data and data['hostaddr'] and data['hostaddr'] != '':
@ -835,7 +836,8 @@ class ServerNode(PGChildNodeView):
status=401,
success=0,
errormsg=gettext(
u"Unable to connect to server:\n\n%s") % errmsg
u"Unable to connect to server:\n\n{}"
).format(errmsg)
)
else:
if 'save_password' in data and data['save_password'] and \
@ -1027,7 +1029,7 @@ class ServerNode(PGChildNodeView):
tunnel_password = server.tunnel_password
else:
tunnel_password = data['tunnel_password'] \
if 'tunnel_password'in data else ''
if 'tunnel_password' in data else ''
save_tunnel_password = data['save_tunnel_password'] \
if tunnel_password and 'save_tunnel_password' in data \
else False

View File

@ -567,7 +567,8 @@ class DatabaseView(PGChildNodeView):
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
# The below SQL will execute CREATE DDL only
SQL = render_template(

View File

@ -368,7 +368,8 @@ class CastView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
try:
sql = render_template("/".join([self.template_path, 'create.sql']),

View File

@ -378,7 +378,7 @@ class EventTriggerView(PGChildNodeView):
status=400,
success=0,
errormsg=gettext(
"Could not find the required parameter %s.") % err
"Could not find the required parameter {}.".format(err))
)
try:
sql = render_template(
@ -636,7 +636,8 @@ class EventTriggerView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter %s.") % err
"Could not find the required parameter {}."
).format(arg)
)
sql = render_template(
"/".join([self.template_path, 'create.sql']),

View File

@ -262,7 +262,8 @@ class ExtensionView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
status, res = self.conn.execute_dict(

View File

@ -65,7 +65,7 @@ class Properties:
@staticmethod
def translate_execute_on_text(execute_on):
if execute_on['type'] == 'host':
return gettext('host %s') % execute_on['value']
return gettext('host {}').format(execute_on['value'])
elif execute_on['type'] == 'per_host':
return gettext('per host')
elif execute_on['type'] == 'master_only':
@ -73,6 +73,6 @@ class Properties:
elif execute_on['type'] == 'all_segments':
return gettext('all segments')
elif execute_on['type'] == 'segment':
return gettext('%s segment') % execute_on['value']
return gettext('{} segment').format(execute_on['value'])
elif execute_on['type'] == 'segments':
return gettext('%d segments') % execute_on['value']
return gettext('{} segments').format(execute_on['value'])

View File

@ -393,7 +393,8 @@ class ForeignDataWrapperView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
try:

View File

@ -388,7 +388,8 @@ class ForeignServerView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
try:
if 'fsrvacl' in data:

View File

@ -396,7 +396,8 @@ class UserMappingView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
try:

View File

@ -453,7 +453,8 @@ class LanguageView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
try:

View File

@ -570,8 +570,8 @@ It may have been removed by another user.
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") %
required_args[arg]
"Could not find the required parameter ({})."
).format(arg)
)
try:
self.format_request_acls(data)

View File

@ -458,7 +458,8 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
if self._check_definition(data):
return make_json_response(

View File

@ -422,7 +422,8 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
# Either copy config or parser must be present in data

View File

@ -379,7 +379,8 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
# Fetch schema name from schema oid
sql = render_template(

View File

@ -354,7 +354,8 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
# Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, 'schema.sql']),

View File

@ -379,7 +379,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
data['schema'] = self.schema

View File

@ -450,7 +450,8 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
try:

View File

@ -908,7 +908,8 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
# Parse privilege data coming from client according to database format
@ -1577,7 +1578,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
return make_json_response(
status=200,
info=gettext("Table rows counted: %s") % count,
info=gettext("Table rows counted: {}").format(count),
data={'total_rows': count}
)

View File

@ -392,8 +392,8 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") %
required_args[arg]
"Could not find the required parameter ({})."
).format(required_args[arg])
)
# Parse privilege data coming from client according to database format

View File

@ -511,8 +511,8 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") %
required_args[arg]
"Could not find the required parameter ({})."
).format(required_args[arg])
)
# Adding parent into data dict, will be using it while creating sql

View File

@ -476,7 +476,8 @@ class CheckConstraintView(PGChildNodeView):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
data['schema'] = self.schema

View File

@ -496,14 +496,16 @@ class ExclusionConstraintView(PGChildNodeView):
status=400,
success=0,
errormsg=_(
"Could not find required parameter (%s).") % str(arg)
"Could not find required parameter ({})."
).format(arg)
)
elif isinstance(data[arg], list) and len(data[arg]) < 1:
return make_json_response(
status=400,
success=0,
errormsg=_(
"Could not find required parameter (%s).") % str(arg)
"Could not find required parameter ({})."
).format(arg)
)
data['schema'] = self.schema

View File

@ -514,14 +514,16 @@ class ForeignKeyConstraintView(PGChildNodeView):
status=400,
success=0,
errormsg=_(
"Could not find required parameter (%s).") % str(arg)
"Could not find required parameter ({})."
).format(arg)
)
elif isinstance(data[arg], list) and len(data[arg]) < 1:
return make_json_response(
status=400,
success=0,
errormsg=_(
"Could not find required parameter (%s).") % str(arg)
"Could not find required parameter ({})."
).format(arg)
)
data['schema'] = self.schema

View File

@ -535,7 +535,7 @@ class IndexConstraintView(PGChildNodeView):
success=0,
errormsg=_(
"Could not find at least one required "
"parameter (%s).") % str(param)
"parameter ({}).".format(str(param)))
)
elif arg not in data:
@ -543,7 +543,8 @@ class IndexConstraintView(PGChildNodeView):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
data['schema'] = self.schema

View File

@ -580,8 +580,8 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
"create index.")
if arg not in data:
err_msg = gettext("Could not find the required parameter (%s)"
".") % required_args[arg]
err_msg = gettext("Could not find the required parameter ({})"
".").format(required_args[arg])
# Check if we have at least one column
if err_msg is not None:
return make_json_response(

View File

@ -946,8 +946,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") %
required_args[arg]
"Could not find the required parameter ({})."
).format(arg)
)
# Additional checks goes here
# If type is range then check if subtype is defined or not

View File

@ -493,7 +493,8 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
try:
SQL, nameOrError = self.getSQL(gid, sid, did, data)
@ -743,7 +744,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
).split('FROM')
if 'definition' in data and (
len(old_def) > 1 or len(new_def) > 1
) and(
) and (
old_def[0] != new_def[0] and
old_def[0] not in new_def[0]
):

View File

@ -284,7 +284,8 @@ SELECT EXISTS(
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
status, res = self.conn.execute_void('BEGIN')

View File

@ -363,7 +363,8 @@ class ResourceGroupView(NodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") % arg
"Could not find the required parameter ({})."
).format(arg)
)
try:
# Below logic will create new resource group

View File

@ -295,8 +295,8 @@ class TablespaceView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s).") %
required_args[arg]
"Could not find the required parameter ({})."
).format(arg)
)
# To format privileges coming from client