lint: Fix calls to _() on computed strings.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2019-04-19 18:49:03 -07:00
committed by Tim Abbott
parent 44dd7c2d95
commit 9a9de156c3
21 changed files with 54 additions and 54 deletions

View File

@@ -124,7 +124,7 @@ def renewal_amount(plan: CustomerPlan, event_time: datetime) -> int: # nocovera
class BillingError(Exception): class BillingError(Exception):
# error messages # error messages
CONTACT_SUPPORT = _("Something went wrong. Please contact %s." % (settings.ZULIP_ADMINISTRATOR,)) CONTACT_SUPPORT = _("Something went wrong. Please contact %s.") % (settings.ZULIP_ADMINISTRATOR,)
TRY_RELOADING = _("Something went wrong. Please reload the page.") TRY_RELOADING = _("Something went wrong. Please reload the page.")
# description is used only for tests # description is used only for tests

View File

@@ -53,7 +53,7 @@ def check_upgrade_parameters(
min_licenses = max(seat_count, MIN_INVOICED_LICENSES) min_licenses = max(seat_count, MIN_INVOICED_LICENSES)
if licenses is None or licenses < min_licenses: if licenses is None or licenses < min_licenses:
raise BillingError('not enough licenses', raise BillingError('not enough licenses',
_("You must invoice for at least {} users.".format(min_licenses))) _("You must invoice for at least {} users.").format(min_licenses))
# Should only be called if the customer is being charged automatically # Should only be called if the customer is being charged automatically
def payment_method_string(stripe_customer: stripe.Customer) -> str: def payment_method_string(stripe_customer: stripe.Customer) -> str:
@@ -62,14 +62,14 @@ def payment_method_string(stripe_customer: stripe.Customer) -> str:
if stripe_source is None: # nocoverage if stripe_source is None: # nocoverage
return _("No payment method on file") return _("No payment method on file")
if stripe_source.object == "card": if stripe_source.object == "card":
return _("%(brand)s ending in %(last4)s" % { return _("%(brand)s ending in %(last4)s") % {
'brand': cast(stripe.Card, stripe_source).brand, 'brand': cast(stripe.Card, stripe_source).brand,
'last4': cast(stripe.Card, stripe_source).last4}) 'last4': cast(stripe.Card, stripe_source).last4}
# There might be one-off stuff we do for a particular customer that # There might be one-off stuff we do for a particular customer that
# would land them here. E.g. by default we don't support ACH for # would land them here. E.g. by default we don't support ACH for
# automatic payments, but in theory we could add it for a customer via # automatic payments, but in theory we could add it for a customer via
# the Stripe dashboard. # the Stripe dashboard.
return _("Unknown payment method. Please contact %s." % (settings.ZULIP_ADMINISTRATOR,)) # nocoverage return _("Unknown payment method. Please contact %s.") % (settings.ZULIP_ADMINISTRATOR,) # nocoverage
@has_request_variables @has_request_variables
def upgrade(request: HttpRequest, user: UserProfile, def upgrade(request: HttpRequest, user: UserProfile,

View File

@@ -1887,7 +1887,7 @@ def recipient_for_user_ids(user_ids: Iterable[int], sender: UserProfile) -> Reci
user_profile = get_user_by_id_in_realm_including_cross_realm( user_profile = get_user_by_id_in_realm_including_cross_realm(
user_id, sender.realm) user_id, sender.realm)
except UserProfile.DoesNotExist: except UserProfile.DoesNotExist:
raise ValidationError(_("Invalid user ID {}".format(user_id))) raise ValidationError(_("Invalid user ID {}").format(user_id))
user_profiles.append(user_profile) user_profiles.append(user_profile)
return recipient_for_user_profiles( return recipient_for_user_profiles(
@@ -2050,23 +2050,23 @@ def check_schedule_message(sender: UserProfile, client: Client,
def check_stream_name(stream_name: str) -> None: def check_stream_name(stream_name: str) -> None:
if stream_name.strip() == "": if stream_name.strip() == "":
raise JsonableError(_("Invalid stream name '%s'" % (stream_name,))) raise JsonableError(_("Invalid stream name '%s'") % (stream_name,))
if len(stream_name) > Stream.MAX_NAME_LENGTH: if len(stream_name) > Stream.MAX_NAME_LENGTH:
raise JsonableError(_("Stream name too long (limit: %s characters)." % (Stream.MAX_NAME_LENGTH,))) raise JsonableError(_("Stream name too long (limit: %s characters).") % (Stream.MAX_NAME_LENGTH,))
for i in stream_name: for i in stream_name:
if ord(i) == 0: if ord(i) == 0:
raise JsonableError(_("Stream name '%s' contains NULL (0x00) characters." % (stream_name,))) raise JsonableError(_("Stream name '%s' contains NULL (0x00) characters.") % (stream_name,))
def check_default_stream_group_name(group_name: str) -> None: def check_default_stream_group_name(group_name: str) -> None:
if group_name.strip() == "": if group_name.strip() == "":
raise JsonableError(_("Invalid default stream group name '%s'" % (group_name,))) raise JsonableError(_("Invalid default stream group name '%s'") % (group_name,))
if len(group_name) > DefaultStreamGroup.MAX_NAME_LENGTH: if len(group_name) > DefaultStreamGroup.MAX_NAME_LENGTH:
raise JsonableError(_("Default stream group name too long (limit: %s characters)" raise JsonableError(_("Default stream group name too long (limit: %s characters)")
% (DefaultStreamGroup.MAX_NAME_LENGTH,))) % (DefaultStreamGroup.MAX_NAME_LENGTH,))
for i in group_name: for i in group_name:
if ord(i) == 0: if ord(i) == 0:
raise JsonableError(_("Default stream group name '%s' contains NULL (0x00) characters." raise JsonableError(_("Default stream group name '%s' contains NULL (0x00) characters.")
% (group_name,))) % (group_name,))
def send_rate_limited_pm_notification_to_bot_owner(sender: UserProfile, def send_rate_limited_pm_notification_to_bot_owner(sender: UserProfile,
realm: Realm, realm: Realm,
@@ -3643,7 +3643,7 @@ def lookup_default_stream_groups(default_stream_group_names: List[str],
default_stream_group = DefaultStreamGroup.objects.get( default_stream_group = DefaultStreamGroup.objects.get(
name=group_name, realm=realm) name=group_name, realm=realm)
except DefaultStreamGroup.DoesNotExist: except DefaultStreamGroup.DoesNotExist:
raise JsonableError(_('Invalid default stream group %s' % (group_name,))) raise JsonableError(_('Invalid default stream group %s') % (group_name,))
default_stream_groups.append(default_stream_group) default_stream_groups.append(default_stream_group)
return default_stream_groups return default_stream_groups
@@ -4053,7 +4053,7 @@ def do_update_message_flags(user_profile: UserProfile,
messages: List[int]) -> int: messages: List[int]) -> int:
valid_flags = [item for item in UserMessage.flags if item not in UserMessage.NON_API_FLAGS] valid_flags = [item for item in UserMessage.flags if item not in UserMessage.NON_API_FLAGS]
if flag not in valid_flags: if flag not in valid_flags:
raise JsonableError(_("Invalid flag: '%s'" % (flag,))) raise JsonableError(_("Invalid flag: '%s'") % (flag,))
flagattr = getattr(UserMessage.flags, flag) flagattr = getattr(UserMessage.flags, flag)
assert messages is not None assert messages is not None
@@ -5394,7 +5394,7 @@ def check_add_user_group(realm: Realm, name: str, initial_members: List[UserProf
user_group = create_user_group(name, initial_members, realm, description=description) user_group = create_user_group(name, initial_members, realm, description=description)
do_send_create_user_group_event(user_group, initial_members) do_send_create_user_group_event(user_group, initial_members)
except django.db.utils.IntegrityError: except django.db.utils.IntegrityError:
raise JsonableError(_("User group '%s' already exists." % (name,))) raise JsonableError(_("User group '%s' already exists.") % (name,))
def do_send_user_group_update_event(user_group: UserGroup, data: Dict[str, Any]) -> None: def do_send_user_group_update_event(user_group: UserGroup, data: Dict[str, Any]) -> None:
event = dict(type="user_group", op='update', group_id=user_group.id, data=data) event = dict(type="user_group", op='update', group_id=user_group.id, data=data)
@@ -5405,7 +5405,7 @@ def do_update_user_group_name(user_group: UserGroup, name: str) -> None:
user_group.name = name user_group.name = name
user_group.save(update_fields=['name']) user_group.save(update_fields=['name'])
except django.db.utils.IntegrityError: except django.db.utils.IntegrityError:
raise JsonableError(_("User group '%s' already exists." % (name,))) raise JsonableError(_("User group '%s' already exists.") % (name,))
do_send_user_group_update_event(user_group, dict(name=name)) do_send_user_group_update_event(user_group, dict(name=name))
def do_update_user_group_description(user_group: UserGroup, description: str) -> None: def do_update_user_group_description(user_group: UserGroup, description: str) -> None:

View File

@@ -37,7 +37,7 @@ def get_user_profiles_by_ids(user_ids: Iterable[int], realm: Realm) -> List[User
try: try:
user_profile = get_user_by_id_in_realm_including_cross_realm(user_id, realm) user_profile = get_user_by_id_in_realm_including_cross_realm(user_id, realm)
except UserProfile.DoesNotExist: except UserProfile.DoesNotExist:
raise JsonableError(_("Invalid user ID {}".format(user_id))) raise JsonableError(_("Invalid user ID {}").format(user_id))
user_profiles.append(user_profile) user_profiles.append(user_profile)
return user_profiles return user_profiles

View File

@@ -50,7 +50,7 @@ def emoji_name_to_emoji_code(realm: Realm, emoji_name: str) -> Tuple[str, str]:
return emoji_name, Reaction.ZULIP_EXTRA_EMOJI return emoji_name, Reaction.ZULIP_EXTRA_EMOJI
if emoji_name in name_to_codepoint: if emoji_name in name_to_codepoint:
return name_to_codepoint[emoji_name], Reaction.UNICODE_EMOJI return name_to_codepoint[emoji_name], Reaction.UNICODE_EMOJI
raise JsonableError(_("Emoji '%s' does not exist" % (emoji_name,))) raise JsonableError(_("Emoji '%s' does not exist") % (emoji_name,))
def check_valid_emoji(realm: Realm, emoji_name: str) -> None: def check_valid_emoji(realm: Realm, emoji_name: str) -> None:
emoji_name_to_emoji_code(realm, emoji_name) emoji_name_to_emoji_code(realm, emoji_name)

View File

@@ -110,7 +110,7 @@ def check_stream_name_available(realm: Realm, name: str) -> None:
def access_stream_by_name(user_profile: UserProfile, def access_stream_by_name(user_profile: UserProfile,
stream_name: str, stream_name: str,
allow_realm_admin: bool=False) -> Tuple[Stream, Recipient, Optional[Subscription]]: allow_realm_admin: bool=False) -> Tuple[Stream, Recipient, Optional[Subscription]]:
error = _("Invalid stream name '%s'" % (stream_name,)) error = _("Invalid stream name '%s'") % (stream_name,)
try: try:
stream = get_realm_stream(stream_name, user_profile.realm_id) stream = get_realm_stream(stream_name, user_profile.realm_id)
except Stream.DoesNotExist: except Stream.DoesNotExist:
@@ -177,7 +177,7 @@ def can_access_stream_history_by_name(user_profile: UserProfile, stream_name: st
if stream.is_history_public_to_subscribers(): if stream.is_history_public_to_subscribers():
# In this case, we check if the user is subscribed. # In this case, we check if the user is subscribed.
error = _("Invalid stream name '%s'" % (stream_name,)) error = _("Invalid stream name '%s'") % (stream_name,)
try: try:
(recipient, sub) = access_stream_common(user_profile, stream, error) (recipient, sub) = access_stream_common(user_profile, stream, error)
except JsonableError: except JsonableError:
@@ -282,4 +282,4 @@ def access_default_stream_group_by_id(realm: Realm, group_id: int) -> DefaultStr
try: try:
return DefaultStreamGroup.objects.get(realm=realm, id=group_id) return DefaultStreamGroup.objects.get(realm=realm, id=group_id)
except DefaultStreamGroup.DoesNotExist: except DefaultStreamGroup.DoesNotExist:
raise JsonableError(_("Default stream group with id '%s' does not exist." % (group_id,))) raise JsonableError(_("Default stream group with id '%s' does not exist.") % (group_id,))

View File

@@ -148,12 +148,12 @@ def user_ids_to_users(user_ids: List[int], realm: Realm) -> List[UserProfile]:
found_user_ids = user_profiles_by_id.keys() found_user_ids = user_profiles_by_id.keys()
missed_user_ids = [user_id for user_id in user_ids if user_id not in found_user_ids] missed_user_ids = [user_id for user_id in user_ids if user_id not in found_user_ids]
if missed_user_ids: if missed_user_ids:
raise JsonableError(_("Invalid user ID: %s" % (missed_user_ids[0],))) raise JsonableError(_("Invalid user ID: %s") % (missed_user_ids[0],))
user_profiles = list(user_profiles_by_id.values()) user_profiles = list(user_profiles_by_id.values())
for user_profile in user_profiles: for user_profile in user_profiles:
if user_profile.realm != realm: if user_profile.realm != realm:
raise JsonableError(_("Invalid user ID: %s" % (user_profile.id,))) raise JsonableError(_("Invalid user ID: %s") % (user_profile.id,))
return user_profiles return user_profiles
def access_bot_by_id(user_profile: UserProfile, user_id: int) -> UserProfile: def access_bot_by_id(user_profile: UserProfile, user_id: int) -> UserProfile:

View File

@@ -60,8 +60,8 @@ def check_capped_string(max_length: int) -> Validator:
if not isinstance(val, str): if not isinstance(val, str):
return _('%s is not a string') % (var_name,) return _('%s is not a string') % (var_name,)
if len(val) > max_length: if len(val) > max_length:
return _("{var_name} is too long (limit: {max_length} characters)".format( return _("{var_name} is too long (limit: {max_length} characters)").format(
var_name=var_name, max_length=max_length)) var_name=var_name, max_length=max_length)
return None return None
return validator return validator
@@ -70,8 +70,8 @@ def check_string_fixed_length(length: int) -> Validator:
if not isinstance(val, str): if not isinstance(val, str):
return _('%s is not a string') % (var_name,) return _('%s is not a string') % (var_name,)
if len(val) != length: if len(val) != length:
return _("{var_name} has incorrect length {length}; should be {target_length}".format( return _("{var_name} has incorrect length {length}; should be {target_length}").format(
var_name=var_name, target_length=length, length=len(val))) var_name=var_name, target_length=length, length=len(val))
return None return None
return validator return validator
@@ -174,7 +174,7 @@ def check_dict(required_keys: Iterable[Tuple[str, Validator]]=[],
optional_keys_set = set(x[0] for x in optional_keys) optional_keys_set = set(x[0] for x in optional_keys)
delta_keys = set(val.keys()) - required_keys_set - optional_keys_set delta_keys = set(val.keys()) - required_keys_set - optional_keys_set
if len(delta_keys) != 0: if len(delta_keys) != 0:
return _("Unexpected arguments: %s" % (", ".join(list(delta_keys)),)) return _("Unexpected arguments: %s") % (", ".join(list(delta_keys)),)
return None return None

View File

@@ -608,8 +608,8 @@ post_delete.connect(flush_realm_emoji, sender=RealmEmoji)
def filter_pattern_validator(value: str) -> None: def filter_pattern_validator(value: str) -> None:
regex = re.compile(r'^(?:(?:[\w\-#_= /:]*|[+]|[!])(\(\?P<\w+>.+\)))+$') regex = re.compile(r'^(?:(?:[\w\-#_= /:]*|[+]|[!])(\(\?P<\w+>.+\)))+$')
error_msg = _('Invalid filter pattern. Valid characters are %s.' % ( error_msg = _('Invalid filter pattern. Valid characters are %s.') % (
'[ a-zA-Z_#=/:+!-]',)) '[ a-zA-Z_#=/:+!-]',)
if not regex.match(str(value)): if not regex.match(str(value)):
raise ValidationError(error_msg) raise ValidationError(error_msg)

View File

@@ -48,7 +48,7 @@ def invite_users_backend(request: HttpRequest, user_profile: UserProfile,
(stream, recipient, sub) = access_stream_by_id(user_profile, stream_id) (stream, recipient, sub) = access_stream_by_id(user_profile, stream_id)
except JsonableError: except JsonableError:
return json_error( return json_error(
_("Stream does not exist with id: {}. No invites were sent.".format(stream_id))) _("Stream does not exist with id: {}. No invites were sent.").format(stream_id))
streams.append(stream) streams.append(stream)
do_invite_users(user_profile, invitee_emails, streams, invite_as) do_invite_users(user_profile, invitee_emails, streams, invite_as)
@@ -128,7 +128,7 @@ def generate_multiuse_invite_backend(
try: try:
(stream, recipient, sub) = access_stream_by_id(user_profile, stream_id) (stream, recipient, sub) = access_stream_by_id(user_profile, stream_id)
except JsonableError: except JsonableError:
return json_error(_("Invalid stream id {}. No invites were sent.".format(stream_id))) return json_error(_("Invalid stream id {}. No invites were sent.").format(stream_id))
streams.append(stream) streams.append(stream)
invite_link = do_create_multiuse_invite_link(user_profile, invite_as, streams) invite_link = do_create_multiuse_invite_link(user_profile, invite_as, streams)

View File

@@ -717,8 +717,8 @@ def get_messages_backend(request: HttpRequest, user_profile: UserProfile,
if anchor is None and not use_first_unread_anchor: if anchor is None and not use_first_unread_anchor:
return json_error(_("Missing 'anchor' argument (or set 'use_first_unread_anchor'=True).")) return json_error(_("Missing 'anchor' argument (or set 'use_first_unread_anchor'=True)."))
if num_before + num_after > MAX_MESSAGES_PER_FETCH: if num_before + num_after > MAX_MESSAGES_PER_FETCH:
return json_error(_("Too many messages requested (maximum %s)." return json_error(_("Too many messages requested (maximum %s).")
% (MAX_MESSAGES_PER_FETCH,))) % (MAX_MESSAGES_PER_FETCH,))
include_history = ok_to_include_history(narrow, user_profile) include_history = ok_to_include_history(narrow, user_profile)
if include_history: if include_history:

View File

@@ -37,7 +37,7 @@ def get_presence_backend(request: HttpRequest, user_profile: UserProfile,
presence_dict = UserPresence.get_status_dict_by_user(target) presence_dict = UserPresence.get_status_dict_by_user(target)
if len(presence_dict) == 0: if len(presence_dict) == 0:
return json_error(_('No presence data for %s' % (target.email,))) return json_error(_('No presence data for %s') % (target.email,))
# For initial version, we just include the status and timestamp keys # For initial version, we just include the status and timestamp keys
result = dict(presence=presence_dict[target.email]) result = dict(presence=presence_dict[target.email])

View File

@@ -73,7 +73,7 @@ def update_realm(
# Additional validation/error checking beyond types go here, so # Additional validation/error checking beyond types go here, so
# the entire request can succeed or fail atomically. # the entire request can succeed or fail atomically.
if default_language is not None and default_language not in get_available_language_codes(): if default_language is not None and default_language not in get_available_language_codes():
raise JsonableError(_("Invalid language '%s'" % (default_language,))) raise JsonableError(_("Invalid language '%s'") % (default_language,))
if description is not None and len(description) > 1000: if description is not None and len(description) > 1000:
return json_error(_("Organization description is too long.")) return json_error(_("Organization description is too long."))
if name is not None and len(name) > Realm.MAX_REALM_NAME_LENGTH: if name is not None and len(name) > Realm.MAX_REALM_NAME_LENGTH:

View File

@@ -40,7 +40,7 @@ def patch_realm_domain(request: HttpRequest, user_profile: UserProfile, domain:
realm_domain = RealmDomain.objects.get(realm=user_profile.realm, domain=domain) realm_domain = RealmDomain.objects.get(realm=user_profile.realm, domain=domain)
do_change_realm_domain(realm_domain, allow_subdomains) do_change_realm_domain(realm_domain, allow_subdomains)
except RealmDomain.DoesNotExist: except RealmDomain.DoesNotExist:
return json_error(_('No entry found for domain %(domain)s.' % {'domain': domain})) return json_error(_('No entry found for domain %(domain)s.') % {'domain': domain})
return json_success() return json_success()
@require_realm_admin @require_realm_admin
@@ -51,5 +51,5 @@ def delete_realm_domain(request: HttpRequest, user_profile: UserProfile,
realm_domain = RealmDomain.objects.get(realm=user_profile.realm, domain=domain) realm_domain = RealmDomain.objects.get(realm=user_profile.realm, domain=domain)
do_remove_realm_domain(realm_domain) do_remove_realm_domain(realm_domain)
except RealmDomain.DoesNotExist: except RealmDomain.DoesNotExist:
return json_error(_('No entry found for domain %(domain)s.' % {'domain': domain})) return json_error(_('No entry found for domain %(domain)s.') % {'domain': domain})
return json_success() return json_success()

View File

@@ -49,7 +49,7 @@ def delete_emoji(request: HttpRequest, user_profile: UserProfile,
if not RealmEmoji.objects.filter(realm=user_profile.realm, if not RealmEmoji.objects.filter(realm=user_profile.realm,
name=emoji_name, name=emoji_name,
deactivated=False).exists(): deactivated=False).exists():
raise JsonableError(_("Emoji '%s' does not exist" % (emoji_name,))) raise JsonableError(_("Emoji '%s' does not exist") % (emoji_name,))
check_emoji_admin(user_profile, emoji_name) check_emoji_admin(user_profile, emoji_name)
do_remove_realm_emoji(user_profile.realm, emoji_name) do_remove_realm_emoji(user_profile.realm, emoji_name)
return json_success() return json_success()

View File

@@ -266,12 +266,12 @@ def you_were_just_subscribed_message(acting_user: UserProfile,
stream_names: Set[str]) -> str: stream_names: Set[str]) -> str:
subscriptions = sorted(list(stream_names)) subscriptions = sorted(list(stream_names))
if len(subscriptions) == 1: if len(subscriptions) == 1:
return _("Hi there! @**%(full_name)s** just subscribed you to the stream #**%(stream_name)s**." % return _("Hi there! @**%(full_name)s** just subscribed you to the stream #**%(stream_name)s**.") % \
{"full_name": acting_user.full_name, {"full_name": acting_user.full_name,
"stream_name": subscriptions[0]}) "stream_name": subscriptions[0]}
message = _("Hi there! @**%(full_name)s** just subscribed you to the following streams:" % message = _("Hi there! @**%(full_name)s** just subscribed you to the following streams:") % \
{"full_name": acting_user.full_name}) {"full_name": acting_user.full_name}
message += "\n\n" message += "\n\n"
for stream_name in subscriptions: for stream_name in subscriptions:
message += "* #**%s**\n" % (stream_name,) message += "* #**%s**\n" % (stream_name,)

View File

@@ -92,7 +92,7 @@ def add_members_to_group_backend(request: HttpRequest, user_profile: UserProfile
for user_profile in user_profiles: for user_profile in user_profiles:
if user_profile.id in existing_member_ids: if user_profile.id in existing_member_ids:
raise JsonableError(_("User %s is already a member of this group" % (user_profile.id,))) raise JsonableError(_("User %s is already a member of this group") % (user_profile.id,))
bulk_add_members_to_user_group(user_group, user_profiles) bulk_add_members_to_user_group(user_group, user_profiles)
return json_success() return json_success()
@@ -107,7 +107,7 @@ def remove_members_from_group_backend(request: HttpRequest, user_profile: UserPr
group_member_ids = get_user_group_members(user_group) group_member_ids = get_user_group_members(user_group)
for member in members: for member in members:
if (member not in group_member_ids): if (member not in group_member_ids):
raise JsonableError(_("There is no member '%s' in this user group" % (member,))) raise JsonableError(_("There is no member '%s' in this user group") % (member,))
remove_members_from_user_group(user_group, user_profiles) remove_members_from_user_group(user_group, user_profiles)
return json_success() return json_success()

View File

@@ -127,15 +127,15 @@ def update_display_settings_backend(
if (default_language is not None and if (default_language is not None and
default_language not in get_available_language_codes()): default_language not in get_available_language_codes()):
raise JsonableError(_("Invalid language '%s'" % (default_language,))) raise JsonableError(_("Invalid language '%s'") % (default_language,))
if (timezone is not None and if (timezone is not None and
timezone not in get_all_timezones()): timezone not in get_all_timezones()):
raise JsonableError(_("Invalid timezone '%s'" % (timezone,))) raise JsonableError(_("Invalid timezone '%s'") % (timezone,))
if (emojiset is not None and if (emojiset is not None and
emojiset not in UserProfile.emojiset_choices()): emojiset not in UserProfile.emojiset_choices()):
raise JsonableError(_("Invalid emojiset '%s'" % (emojiset,))) raise JsonableError(_("Invalid emojiset '%s'") % (emojiset,))
request_settings = {k: v for k, v in list(locals().items()) if k in user_profile.property_types} request_settings = {k: v for k, v in list(locals().items()) if k in user_profile.property_types}
result = {} # type: Dict[str, Any] result = {} # type: Dict[str, Any]

View File

@@ -159,7 +159,7 @@ def api_librato_webhook(request: HttpRequest, user_profile: UserProfile,
try: try:
content = message_handler.handle() content = message_handler.handle()
except Exception as e: except Exception as e:
return json_error(_(str(e))) return json_error(str(e))
check_send_webhook_message(request, user_profile, topic, content) check_send_webhook_message(request, user_profile, topic, content)
return json_success() return json_success()

View File

@@ -42,7 +42,7 @@ def api_wordpress_webhook(request: HttpRequest, user_profile: UserProfile,
data = WP_LOGIN_TEMPLATE.format(name=user_login) data = WP_LOGIN_TEMPLATE.format(name=user_login)
else: else:
return json_error(_("Unknown WordPress webhook action: " + hook)) return json_error(_("Unknown WordPress webhook action: %s") % (hook,))
topic = 'WordPress Notification' topic = 'WordPress Notification'

View File

@@ -155,7 +155,7 @@ def validate_count_stats(server: RemoteZulipServer, model: Any,
last_id = get_last_id_from_server(server, model) last_id = get_last_id_from_server(server, model)
for item in counts: for item in counts:
if item['property'] not in COUNT_STATS: if item['property'] not in COUNT_STATS:
raise JsonableError(_("Invalid property %s" % (item['property'],))) raise JsonableError(_("Invalid property %s") % (item['property'],))
if item['id'] <= last_id: if item['id'] <= last_id:
raise JsonableError(_("Data is out of order.")) raise JsonableError(_("Data is out of order."))
last_id = item['id'] last_id = item['id']