mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 23:43:43 +00:00
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
b114eb2f10
commit
69730a78cc
@@ -292,7 +292,7 @@ def upload_image_to_s3(
|
||||
key = bucket.Object(file_name)
|
||||
metadata = {
|
||||
"user_profile_id": str(user_profile.id),
|
||||
"realm_id": str(user_profile.realm_id)
|
||||
"realm_id": str(user_profile.realm_id),
|
||||
}
|
||||
|
||||
content_disposition = ''
|
||||
@@ -378,7 +378,7 @@ class S3UploadBackend(ZulipUploadBackend):
|
||||
s3_file_name = "/".join([
|
||||
str(target_realm.id),
|
||||
random_name(18),
|
||||
sanitize_name(uploaded_file_name)
|
||||
sanitize_name(uploaded_file_name),
|
||||
])
|
||||
url = f"/user_uploads/{s3_file_name}"
|
||||
|
||||
@@ -387,7 +387,7 @@ class S3UploadBackend(ZulipUploadBackend):
|
||||
s3_file_name,
|
||||
content_type,
|
||||
user_profile,
|
||||
file_data
|
||||
file_data,
|
||||
)
|
||||
|
||||
create_attachment(uploaded_file_name, s3_file_name, user_profile, uploaded_file_size)
|
||||
@@ -415,7 +415,7 @@ class S3UploadBackend(ZulipUploadBackend):
|
||||
s3_file_name + "-medium.png",
|
||||
"image/png",
|
||||
target_user_profile,
|
||||
resized_medium
|
||||
resized_medium,
|
||||
)
|
||||
|
||||
resized_data = resize_avatar(image_data)
|
||||
@@ -565,7 +565,7 @@ class S3UploadBackend(ZulipUploadBackend):
|
||||
s3_file_name + "-medium.png",
|
||||
"image/png",
|
||||
user_profile,
|
||||
resized_medium
|
||||
resized_medium,
|
||||
)
|
||||
|
||||
def ensure_basic_avatar_image(self, user_profile: UserProfile) -> None: # nocoverage
|
||||
@@ -585,7 +585,7 @@ class S3UploadBackend(ZulipUploadBackend):
|
||||
s3_file_name,
|
||||
"image/png",
|
||||
user_profile,
|
||||
resized_avatar
|
||||
resized_avatar,
|
||||
)
|
||||
|
||||
def upload_emoji_image(self, emoji_file: File, emoji_file_name: str,
|
||||
@@ -594,7 +594,7 @@ class S3UploadBackend(ZulipUploadBackend):
|
||||
bucket_name = settings.S3_AVATAR_BUCKET
|
||||
emoji_path = RealmEmoji.PATH_ID_TEMPLATE.format(
|
||||
realm_id=user_profile.realm_id,
|
||||
emoji_file_name=emoji_file_name
|
||||
emoji_file_name=emoji_file_name,
|
||||
)
|
||||
|
||||
image_data = emoji_file.read()
|
||||
@@ -640,9 +640,9 @@ class S3UploadBackend(ZulipUploadBackend):
|
||||
'get_object',
|
||||
Params={
|
||||
'Bucket': bucket.name,
|
||||
'Key': key.key
|
||||
'Key': key.key,
|
||||
},
|
||||
ExpiresIn=0
|
||||
ExpiresIn=0,
|
||||
)
|
||||
return public_url
|
||||
|
||||
@@ -710,7 +710,7 @@ class LocalUploadBackend(ZulipUploadBackend):
|
||||
str(user_profile.realm_id),
|
||||
format(random.randint(0, 255), 'x'),
|
||||
random_name(18),
|
||||
sanitize_name(uploaded_file_name)
|
||||
sanitize_name(uploaded_file_name),
|
||||
])
|
||||
|
||||
write_local_file('files', path, file_data)
|
||||
@@ -832,7 +832,7 @@ class LocalUploadBackend(ZulipUploadBackend):
|
||||
user_profile: UserProfile) -> None:
|
||||
emoji_path = RealmEmoji.PATH_ID_TEMPLATE.format(
|
||||
realm_id= user_profile.realm_id,
|
||||
emoji_file_name=emoji_file_name
|
||||
emoji_file_name=emoji_file_name,
|
||||
)
|
||||
|
||||
image_data = emoji_file.read()
|
||||
|
||||
Reference in New Issue
Block a user