mirror of https://github.com/zulip/zulip.git
zthumbor: Clean up type ignores.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
d56a5bdd88
commit
58adac5663
|
@ -27,7 +27,7 @@ def get_not_found_result():
|
||||||
def load(context, url, callback):
|
def load(context, url, callback):
|
||||||
# type: (Context, str, Callable[..., Any]) -> None
|
# type: (Context, str, Callable[..., Any]) -> None
|
||||||
source_type, encoded_url = separate_url_and_source_type(url)
|
source_type, encoded_url = separate_url_and_source_type(url)
|
||||||
actual_url = base64.urlsafe_b64decode(urllib.parse.unquote(encoded_url))
|
actual_url = base64.urlsafe_b64decode(urllib.parse.unquote(encoded_url)).decode('utf-8')
|
||||||
if source_type not in (THUMBOR_S3_TYPE, THUMBOR_LOCAL_FILE_TYPE,
|
if source_type not in (THUMBOR_S3_TYPE, THUMBOR_LOCAL_FILE_TYPE,
|
||||||
THUMBOR_EXTERNAL_TYPE):
|
THUMBOR_EXTERNAL_TYPE):
|
||||||
callback(get_not_found_result())
|
callback(get_not_found_result())
|
||||||
|
@ -35,20 +35,20 @@ def load(context, url, callback):
|
||||||
return
|
return
|
||||||
|
|
||||||
if source_type == THUMBOR_S3_TYPE:
|
if source_type == THUMBOR_S3_TYPE:
|
||||||
if actual_url.startswith('/user_uploads/'): # type: ignore # python 2 type differs from python 3 type
|
if actual_url.startswith('/user_uploads/'):
|
||||||
actual_url = actual_url[len('/user_uploads/'):]
|
actual_url = actual_url[len('/user_uploads/'):]
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unexpected s3 file.")
|
raise AssertionError("Unexpected s3 file.")
|
||||||
|
|
||||||
s3_loader.load(context, actual_url, callback)
|
s3_loader.load(context, actual_url, callback)
|
||||||
elif source_type == THUMBOR_LOCAL_FILE_TYPE:
|
elif source_type == THUMBOR_LOCAL_FILE_TYPE:
|
||||||
if actual_url.startswith('/user_uploads/'): # type: ignore # python 2 type differs from python 3 type
|
if actual_url.startswith('/user_uploads/'):
|
||||||
actual_url = actual_url[len('/user_uploads/'):]
|
actual_url = actual_url[len('/user_uploads/'):]
|
||||||
local_file_path_prefix = 'files/'
|
local_file_path_prefix = 'files/'
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unexpected local file.")
|
raise AssertionError("Unexpected local file.")
|
||||||
|
|
||||||
patched_local_url = local_file_path_prefix + actual_url # type: ignore # python 2 type differs from python 3 type
|
patched_local_url = local_file_path_prefix + actual_url
|
||||||
file_loader.load(context, patched_local_url, callback)
|
file_loader.load(context, patched_local_url, callback)
|
||||||
elif source_type == THUMBOR_EXTERNAL_TYPE:
|
elif source_type == THUMBOR_EXTERNAL_TYPE:
|
||||||
https_loader.load(context, actual_url, callback)
|
https_loader.load(context, actual_url, callback)
|
||||||
|
|
Loading…
Reference in New Issue