mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 10:57:58 +00:00
python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
11741543da
commit
6e4c3e41dc
@@ -9,7 +9,7 @@ from zerver.models import Stream
|
||||
|
||||
def default_option_handler_factory(address_option: str) -> Callable[[Dict[str, Any]], None]:
|
||||
def option_setter(options_dict: Dict[str, Any]) -> None:
|
||||
options_dict[address_option.replace('-', '_')] = True
|
||||
options_dict[address_option.replace("-", "_")] = True
|
||||
|
||||
return option_setter
|
||||
|
||||
@@ -28,7 +28,7 @@ class ZulipEmailForwardError(Exception):
|
||||
|
||||
|
||||
def get_email_gateway_message_string_from_address(address: str) -> str:
|
||||
pattern_parts = [re.escape(part) for part in settings.EMAIL_GATEWAY_PATTERN.split('%s')]
|
||||
pattern_parts = [re.escape(part) for part in settings.EMAIL_GATEWAY_PATTERN.split("%s")]
|
||||
if settings.EMAIL_GATEWAY_EXTRA_PATTERN_HACK:
|
||||
# Accept mails delivered to any Zulip server
|
||||
pattern_parts[-1] = settings.EMAIL_GATEWAY_EXTRA_PATTERN_HACK
|
||||
@@ -36,7 +36,7 @@ def get_email_gateway_message_string_from_address(address: str) -> str:
|
||||
match = match_email_re.match(address)
|
||||
|
||||
if not match:
|
||||
raise ZulipEmailForwardError('Address not recognized by gateway.')
|
||||
raise ZulipEmailForwardError("Address not recognized by gateway.")
|
||||
msg_string = match.group(1)
|
||||
|
||||
return msg_string
|
||||
@@ -48,8 +48,8 @@ def encode_email_address(stream: Stream, show_sender: bool = False) -> str:
|
||||
|
||||
def encode_email_address_helper(name: str, email_token: str, show_sender: bool = False) -> str:
|
||||
# Some deployments may not use the email gateway
|
||||
if settings.EMAIL_GATEWAY_PATTERN == '':
|
||||
return ''
|
||||
if settings.EMAIL_GATEWAY_PATTERN == "":
|
||||
return ""
|
||||
|
||||
# Given the fact that we have almost no restrictions on stream names and
|
||||
# that what characters are allowed in e-mail addresses is complicated and
|
||||
@@ -59,9 +59,9 @@ def encode_email_address_helper(name: str, email_token: str, show_sender: bool =
|
||||
# 3. If the resulting name is shorter than the name we got in step 1,
|
||||
# it means some letters can't be reasonably turned to ascii and have to be dropped,
|
||||
# which would mangle the name, so we just skip the name part of the address.
|
||||
name = re.sub(r"\W+", '-', name)
|
||||
name = re.sub(r"\W+", "-", name)
|
||||
slug_name = slugify(name)
|
||||
encoded_name = slug_name if len(slug_name) == len(name) else ''
|
||||
encoded_name = slug_name if len(slug_name) == len(name) else ""
|
||||
|
||||
# If encoded_name ends up empty, we just skip this part of the address:
|
||||
if encoded_name:
|
||||
@@ -89,9 +89,9 @@ def decode_email_address(email: str) -> Tuple[str, Dict[str, bool]]:
|
||||
# We need to keep supporting `+` indefinitely for backwards
|
||||
# compatibility with older versions of Zulip that offered users
|
||||
# email addresses prioritizing using `+` for better aesthetics.
|
||||
msg_string = msg_string.replace('.', '+')
|
||||
msg_string = msg_string.replace(".", "+")
|
||||
|
||||
parts = msg_string.split('+')
|
||||
parts = msg_string.split("+")
|
||||
options: Dict[str, bool] = {}
|
||||
for part in parts:
|
||||
if part in optional_address_tokens:
|
||||
|
||||
Reference in New Issue
Block a user