mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 09:22:31 -05:00
Update dependencies and copyright year (#2436)
- aiohttp 3.5 - websockets 7 - Rapptz/discord.py@700dbb5 - A few others Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"""
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2017 Rapptz
|
||||
Copyright (c) 2015-2019 Rapptz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
@@ -26,6 +26,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import array
|
||||
import asyncio
|
||||
import unicodedata
|
||||
from base64 import b64encode
|
||||
from bisect import bisect_left
|
||||
import datetime
|
||||
@@ -33,7 +34,7 @@ from email.utils import parsedate_to_datetime
|
||||
import functools
|
||||
from inspect import isawaitable as _isawaitable
|
||||
import json
|
||||
from re import split as re_split
|
||||
import re
|
||||
import warnings
|
||||
|
||||
from .errors import InvalidArgument
|
||||
@@ -83,7 +84,7 @@ def cached_slot_property(name):
|
||||
|
||||
def parse_time(timestamp):
|
||||
if timestamp:
|
||||
return datetime.datetime(*map(int, re_split(r"[^\d]", timestamp.replace("+00:00", ""))))
|
||||
return datetime.datetime(*map(int, re.split(r"[^\d]", timestamp.replace("+00:00", ""))))
|
||||
return None
|
||||
|
||||
|
||||
@@ -265,9 +266,7 @@ def _get_mime_type_for_image(data):
|
||||
return "image/png"
|
||||
elif data.startswith(b"\xFF\xD8") and data.rstrip(b"\0").endswith(b"\xFF\xD9"):
|
||||
return "image/jpeg"
|
||||
elif data.startswith(b"\x47\x49\x46\x38\x37\x61") or data.startswith(
|
||||
b"\x47\x49\x46\x38\x39\x61"
|
||||
):
|
||||
elif data.startswith((b"\x47\x49\x46\x38\x37\x61", b"\x47\x49\x46\x38\x39\x61")):
|
||||
return "image/gif"
|
||||
elif data.startswith(b"RIFF") and data[8:12] == b"WEBP":
|
||||
return "image/webp"
|
||||
@@ -351,3 +350,20 @@ class SnowflakeList(array.array):
|
||||
def has(self, element):
|
||||
i = bisect_left(self, element)
|
||||
return i != len(self) and self[i] == element
|
||||
|
||||
|
||||
_IS_ASCII = re.compile(r"^[\x00-\x7f]+$")
|
||||
|
||||
|
||||
def _string_width(string, *, _IS_ASCII=_IS_ASCII):
|
||||
"""Returns string's width."""
|
||||
match = _IS_ASCII.match(string)
|
||||
if match:
|
||||
return match.endpos
|
||||
|
||||
UNICODE_WIDE_CHAR_TYPE = "WFA"
|
||||
width = 0
|
||||
func = unicodedata.east_asian_width
|
||||
for char in string:
|
||||
width += 2 if func(char) in UNICODE_WIDE_CHAR_TYPE else 1
|
||||
return width
|
||||
|
||||
Reference in New Issue
Block a user