fixing fstring

This commit is contained in:
trhr 2020-04-16 05:53:51 -05:00
parent e0c868fc53
commit 5c51bb7e97
9 changed files with 17 additions and 19 deletions

View file

@ -279,7 +279,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
return
if not obj.access(self, "puppet"):
# no access
self.msg(_(f"You don't have permission to puppet '{obj.key}'."))
self.msg(_("You don't have permission to puppet '{key}'.".format(key=obj.key)))
return
if obj.account:
# object already puppeted
@ -300,7 +300,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
self.unpuppet_object(obj.sessions.get())
elif obj.account.is_connected:
# controlled by another account
self.msg(_(f"|c{obj.key}|R is already puppeted by another Account."))
self.msg(_("|c{key}|R is already puppeted by another Account.".format(key=obj.key)))
return
# do the puppeting
@ -1305,7 +1305,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
"""
reason = f" ({reason if reason else ''})"
self._send_to_connect_channel(_(f"|R{self.key} disconnected{reason}|n"))
self._send_to_connect_channel(_("|R{key} disconnected{reason}|n".format(key=self.key)))
def at_post_disconnect(self, **kwargs):
"""
@ -1411,7 +1411,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
if hasattr(target, "return_appearance"):
return target.return_appearance(self)
else:
return _(f"{target} has no in-game appearance.")
return _("{target} has no in-game appearance.".format(target=target))
else:
# list of targets - make list to disconnect from db
characters = list(tar for tar in target if tar) if target else []
@ -1589,7 +1589,7 @@ class DefaultGuest(DefaultAccount):
overriding the call (unused by default).
"""
self._send_to_connect_channel(_(f"|G{self.key} connected|n"))
self._send_to_connect_channel(_("|G{key} connected|n".format(key=self.key)))
self.puppet_object(session, self.db._last_puppet)
def at_server_shutdown(self):

View file

@ -329,7 +329,7 @@ class IRCBot(Bot):
chstr = f"{self.db.irc_channel} ({self.db.irc_network}:{self.db.irc_port})"
nicklist = ", ".join(sorted(kwargs["nicklist"], key=lambda n: n.lower()))
for obj in self._nicklist_callers:
obj.msg(_(f"Nicks at {chstr}:\n {nicklist}"))
obj.msg(_("Nicks at {chstr}:\n {nicklist}".format(chstr=chstr, nicklist=nicklist)))
self._nicklist_callers = []
return
@ -338,7 +338,7 @@ class IRCBot(Bot):
if hasattr(self, "_ping_callers") and self._ping_callers:
chstr = f"{self.db.irc_channel} ({self.db.irc_network}:{self.db.irc_port})"
for obj in self._ping_callers:
obj.msg(_(f"IRC ping return from {chstr} took {kwargs['timing']}s."))
obj.msg(_("IRC ping return from {chstr} took {time}s.".format(chstr=chstr, time=kwargs['timing'])))
self._ping_callers = []
return

View file

@ -743,7 +743,7 @@ def cmdhandler(
sysarg = raw_string
else:
# fallback to default error text
sysarg = _("Command '%s' is not available.") % raw_string
sysarg = _("Command '{command}' is not available.".format(command=raw_string))
suggestions = string_suggestions(
raw_string,
cmdset.get_all_cmd_keys_and_aliases(caller),
@ -751,9 +751,7 @@ def cmdhandler(
maxnum=3,
)
if suggestions:
sysarg += _(" Maybe you meant %s?") % utils.list_to_string(
suggestions, _("or"), addquote=True
)
sysarg += _(" Maybe you meant {command}?".format(command=utils.list_to_string(suggestions, _("or"), addquote=True)))
else:
sysarg += _(' Type "help" for help.')
raise ExecSystemCommand(syscmd, sysarg)

View file

@ -184,7 +184,7 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
raise exc.with_traceback(tb)
else:
# try next suggested path
errstring += _("\n(Unsuccessfully tried '%s')." % python_path)
errstring += _("\n(Unsuccessfully tried '{path}').".format(path=python_path))
continue
try:
cmdsetclass = getattr(module, classname)
@ -194,7 +194,7 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
dum, dum, tb = sys.exc_info()
raise exc.with_traceback(tb)
else:
errstring += _("\n(Unsuccessfully tried '%s')." % python_path)
errstring += _("\n(Unsuccessfully tried '{path}').".format(path=python_path))
continue
_CACHED_CMDSETS[python_path] = cmdsetclass

View file

@ -131,7 +131,7 @@ class HelpEntryManager(TypedObjectManager):
for topic in topics:
topic.help_category = default_category
topic.save()
string = _(f"Help database moved to category {default_category}")
string = _("Help database moved to category {default_category}".format(default_category=default_category))
logger.log_info(string)
def search_help(self, ostring, help_category=None):

View file

@ -246,7 +246,7 @@ class LockHandler(object):
evalstring = " ".join(_RE_OK.findall(evalstring))
eval(evalstring % tuple(True for func in funclist), {}, {})
except Exception:
elist.append(_("Lock: definition '%s' has syntax errors.") % raw_lockstring)
elist.append(_("Lock: definition '{lock_string}' has syntax errors.".format(lock_string=raw_lockstring)))
continue
if access_type in locks:
duplicates += 1

View file

@ -1055,7 +1055,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
# See if we need to kick the account off.
for session in self.sessions.all():
session.msg(_("Your character %s has been destroyed.") % self.key)
session.msg(_("Your character {key} has been destroyed.".format(key=self.key)))
# no need to disconnect, Account just jumps to OOC mode.
# sever the connection (important!)
if self.account:

View file

@ -1916,7 +1916,7 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs):
if multimatch_string:
error = "%s\n" % multimatch_string
else:
error = _("More than one match for '%s' (please narrow target):\n" % query)
error = _("More than one match for '{query}' (please narrow target):\n".format(query=query))
for num, result in enumerate(matches):
# we need to consider Commands, where .aliases is a list

View file

@ -59,7 +59,7 @@ def datetime(entry, option_key="Datetime", account=None, from_tz=None, **kwargs)
"""
if not entry:
raise ValueError(_(f"No {option_key} entered!"))
raise ValueError(_("No {option_key} entered!".format(option_key=option_key)))
if not from_tz:
from_tz = _pytz.UTC
if account:
@ -67,7 +67,7 @@ def datetime(entry, option_key="Datetime", account=None, from_tz=None, **kwargs)
try:
from_tz = _pytz.timezone(acct_tz)
except Exception as err:
raise ValueError(_(f"Timezone string '{acct_tz}' is not a valid timezone ({err})"))
raise ValueError(_("Timezone string '{acct_tz}' is not a valid timezone ({err})".format(acct_tz=acct_tz, err=err)))
else:
from_tz = _pytz.UTC