A Python utility.
Project description
wftutil
☤ The Basics
WTF A Python utility / library
☤ Installation
Of course, the recommended installation method is pipenv <http://pipenv.org>
_::
pipenv install wtfutil
or
pip install wtfutil
☤ Features
fileutil
sqlutil
notifyutil
httputil
hashutil
strutil
Internally, numerous optimizations have been implemented for Python requests, such as resolving HTTPS proxy issues on Windows, removing SSL verification, and addressing urllib3 warnings, among others
urllib3.disable_warnings()
remove_ssl_verify()
patch_redirect()
patch_getproxies()
☤ Example
☤ HTTP Request
from wtfutil import util
# 1. get requests session
# def requests_session(proxies=False, max_retries=1, timeout=30, debug=False, base_url=None, user_agent=None, use_cache=None):
req1 = util.requests_session(timeout=30, max_retries=1)
req1.post('http://localhost:8080/xxx')
req2 = util.requests_session(base_url='http://localhost:8080', timeout=30, max_retries=1)
req2.post('/xxx/update')
from wtfutil import util
# send http raw
util.httpraw('''
POST /a/bbbb?id=1&type=jsp HTTP/1.1
Host: abc.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:88.0) Gecko/20100101 Firefox/88.0
Content-Length: 1
Accept-Charset: utf-8
Content-Type: multipart/; boundary=----WebKitFormBoundaryzxcxzcxz
Accept-Encoding: gzip
------WebKitFormBoundaryzxcxzcxz
Content-Disposition: form-data; name="upload";filename="f.jsp"
test
------WebKitFormBoundaryzxcxzcxz
Content-Disposition: form-data; name="submit"
submit
------WebKitFormBoundaryzxcxzcxz--
''')
☤ String、File IO
from wtfutil import util
# read and write file
# def read_lines(filepath, encoding='utf-8', not_exists_ok: bool = False) -> list:
urls = util.read_lines('input_url.txt')
# def read_text(filepath, encoding='utf-8', not_exists_ok: bool = False) -> str:
data = util.read_text('input.txt')
data_bytes = util.read_bytes('input.txt')
# def write_text(filepath, content, mode='w', encoding='utf-8'):
util.write_text('output.txt', 'test')
util.write_lines('output.txt', ['te','st'])
...
# like py3.9 removesuffix
util.removesuffix('test123456', '456')
util.removeprefix('test123456', 'test')
util.str_to_bool('yes')
util.write_json('/tmp/test.json', {})
☤ Encode / Decode
from wtfutil import util
# encode, decode
util.base64encode(data)
util.base64decode(data)
util.base64urlencode(data)
util.base64urldecode(data)
util.uuencode(data)
util.url_encode_all(data)
# hash
util.str_md5('xxx')
util.str_sha1('xxx')
util.file_md5('/etc/hosts')
util.str_sha1('/etc/hosts')
...
☤ Encrypt / Decrypt
from wtfutil import util
util.rsa_encrypt
util.rsa_decrypt
util.des_encrypt
util.des_decrypt
...
☤ Thank You
Thanks for checking this library out! I hope you find it useful.
Of course, there's always room for improvement. Feel free to https://github.com/vicrack
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for wtfutil-1.0.37-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f3395ecd4eb6c9b0377ea414551c7655b1b958f1a3dbe6a631b3b8f9b94ff7c |
|
MD5 | 8af3acba8917e0daa0dce7a86508850c |
|
BLAKE2b-256 | 250e2d4ee7ff758a74eb61df6c59eddd6fe1302d0b150cd850d26b501c30ade7 |