|
24 | 24 | from itertools import chain |
25 | 25 | from threading import local |
26 | 26 | from time import gmtime, strftime |
| 27 | +from typing import AnyStr, Optional, Union |
27 | 28 |
|
28 | 29 | import iso8601 |
29 | 30 | import pkg_resources |
30 | 31 | import requests |
31 | | -import six |
32 | 32 | import xmlsec |
33 | | -import yaml |
34 | 33 | from _collections_abc import Mapping, MutableMapping |
35 | 34 | from apscheduler.executors.pool import ThreadPoolExecutor |
36 | 35 | from apscheduler.jobstores.memory import MemoryJobStore |
|
43 | 42 | from requests.structures import CaseInsensitiveDict |
44 | 43 | from requests_cache import CachedSession |
45 | 44 | from requests_file import FileAdapter |
46 | | -from six.moves.urllib_parse import quote_plus, urlparse |
| 45 | +from six.moves.urllib_parse import urlparse |
47 | 46 |
|
48 | 47 | from . import __version__ |
49 | 48 | from .constants import NS, config |
@@ -720,21 +719,21 @@ def url_get(url): |
720 | 719 | return r |
721 | 720 |
|
722 | 721 |
|
723 | | -def safe_b64e(data): |
724 | | - if not isinstance(data, six.binary_type): |
| 722 | +def safe_b64e(data: Union[str, bytes]) -> str: |
| 723 | + if not isinstance(data, bytes): |
725 | 724 | data = data.encode("utf-8") |
726 | 725 | return base64.b64encode(data).decode('ascii') |
727 | 726 |
|
728 | 727 |
|
729 | | -def safe_b64d(s): |
| 728 | +def safe_b64d(s: str) -> bytes: |
730 | 729 | return base64.b64decode(s) |
731 | 730 |
|
732 | 731 |
|
733 | 732 | # data:<class 'type'>;base64, |
734 | 733 | # data:<class 'type'>;base64, |
735 | 734 |
|
736 | 735 |
|
737 | | -def img_to_data(data, content_type): |
| 736 | +def img_to_data(data: bytes, content_type: str) -> Optional[str]: |
738 | 737 | """Convert a file (specified by a path) into a data URI.""" |
739 | 738 | mime_type, options = cgi.parse_header(content_type) |
740 | 739 | data64 = None |
|
0 commit comments