Encapsulate some common tool methods
Project description
liangutil包
说明:以Liang开头的类是单独写的类,以Utils结尾的都是基于第三方库封装的。函数详细说明请看代码注释。
安装
pip install liangutil
liangutils
函数列表:
- is_filepath(path):判断路径是否为文件路径
- get_dirpath(path):根据文件路径获得其父级目录路径
- check_path(path):检查路径是否存在
- print_log(level, content):打印日志
- code_location(depth=-2):获得调用该方法的函数在哪里
- get_nowdatetime():获得现在的日期时间
- get_nowtime(now):获得现在的时间
- get_nowdate(now):获得现在的日期
requestutils
RequestUtils
基于Requests库的封装
函数列表:
- get_header(self, is_choice_agent=False):获得请求头
- get(self, url, header="", retry_count=3, is_response_json=False, time_sleep=1, proxy=None):Get请求
mysqlutils
MySQLUtils
基于pymysql库的封装
函数列表:
- check_table_exist(self, table_name):根据表名检查表是否存在
- insert_data(self, table_name, data: dict):向数据表插入一条记录
- insert_datas(self, table_name, data_list: list):向数据表中插入多条记录
lianglog
LiangLog
依赖于 MySQLUtils
函数列表:
- print_log(self, level, content):打印日志到控制台
- record_log_to_file(self,level, content):将日志输出到文件
- record_log_to_db(self, level, content):将日志输出到mysql数据库中
- record_log(self, level, content):记录日志总方法
字段名 | 类型 | 长度 |
---|---|---|
datetime | varchar | 32 |
level | varchar | 32 |
name | varchar | 32 |
content | varchar | 255 |
redisutils
RedisUtils
基于redis库的封装
函数列表:
- enqueue_message(self, message):向redis插入条数据
minioutils
MinIOUtils
基于minio库的封装,依赖于 RedisUtils
函数列表
- get_configfile(self):读取配置文件
- upload_file_to_minio(self, bucket_name: str, file_path: str, current_path: str):将文件上传至MinIO
- upload_file_to_minio_notify(self, bucket_name: str, file_path: str, current_path: str):将文件上传至MinIO,并向Redis通知
更新日志
2023年
7月
2023-7-31 V0.0.6
第一个发布版本
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 Distribution
liangutil-0.0.8.tar.gz
(10.6 kB
view hashes)
Built Distribution
liangutil-0.0.8-py3-none-any.whl
(11.2 kB
view hashes)
Close
Hashes for liangutil-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05388be09f9431e1117f87bf43b5022168c722efb322d8552be38928eb9b12e7 |
|
MD5 | 342a4a9f38425eb7232d00390ff5c91f |
|
BLAKE2b-256 | d8d535e187f2efe50b6e5268a0a81387c7c0102e9bef742adf274180997412ee |