py.lib.aw_web_tools
2024-02-25
py.lib.aw_web_tools/src/aw_web_tools/url.py
..init
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/aw_web_tools/url.py Sun Feb 25 15:18:36 2024 +0300 1.3 @@ -0,0 +1,20 @@ 1.4 +# coding: utf-8 -*- 1.5 +# Инструменты для работы с URL 1.6 +from base64 import urlsafe_b64encode as _b64e, urlsafe_b64decode as _b64d 1.7 +from urllib.parse import quote, unquote 1.8 + 1.9 + 1.10 +def b64_encode(buf: str) -> str: 1.11 + return _b64e(buf.encode('UTF-8')).decode('UTF-8') 1.12 + 1.13 + 1.14 +def b64_decode(buf: str) -> str: 1.15 + return _b64d(buf.encode('UTF-8')).decode('UTF-8') 1.16 + 1.17 + 1.18 +def url_quote(buf: str) -> str: 1.19 + return quote(buf) 1.20 + 1.21 + 1.22 +def url_unquote(buf: str) -> str: 1.23 + return unquote(buf)