一套实用的 Python 工具库,包含日志、时间处理和多线程相关的工具函数
Project description
Ginkgo Tools
一套实用的 Python 工具库,包含日志、时间处理和多线程相关的工具函数。
功能模块
日志工具 (tools_log)
- console_log_debug: 标准的打印函数,输出时间、内容、调用的文件和函数,便于调试和问题追踪
时间工具 (tools_time)
- trans_timestr_to_datetime: 将多种格式的时间字符串转换为 datetime 对象
- trans_timestr_to_stddatestr: 将时间字符串转换为标准日期格式字符串
- trans_datetime_to_describe: 将 datetime 对象转换为描述性信息字典
- get_week_dates: 获取指定日期所在周的日期列表
- get_week_range: 获取指定日期所在周的开始和结束时间范围
- get_month_range: 获取指定日期所在月的开始和结束时间范围
- get_quarter_range: 获取指定日期所在季度的开始和结束时间范围
- get_year_range: 获取指定日期所在年的开始和结束时间范围
- get_offset_date: 获取相对于今天的偏移日期
- create_timestamp_mark: 创建时间戳标记(用于文件名等场景)
- create_time_mark: 创建时间标记(精确到毫秒,用于临时文件名等场景)
- analyse_filename_time: 从文件名中提取时间信息
- analyse_fileattr_time: 从文件属性中获取修改时间
多线程工具 (tools_threading_target)
- Base_Operation_Threading_Target: 异步任务对象基类,用于创建多线程任务
安装
pip install ginkgo-tools
使用示例
日志工具使用示例
from ginkgo_tools import console_log_debug
# 打印调试信息
console_log_debug("这是一条调试信息", "变量值:", variable)
# 异常处理中的日志打印
try:
# 一些可能出错的代码
pass
except Exception:
console_log_debug("发生异常", onException=True)
时间工具使用示例
from ginkgo_tools import (
trans_timestr_to_datetime,
get_week_range,
create_time_mark
)
# 时间字符串转换
dt = trans_timestr_to_datetime("2024-03-08T16:34")
# 获取本周时间范围
week_start, week_end = get_week_range()
# 创建时间标记
time_mark = create_time_mark()
多线程工具使用示例
from ginkgo_tools import Base_Operation_Threading_Target
class MyThreadTask(Base_Operation_Threading_Target):
def run(self):
# 实现具体的任务逻辑
pass
# 创建并启动线程任务
task = MyThreadTask(target_object, operation_dict)
task.start()
支持的 Python 版本
- Python 3.6
- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10
- Python 3.11
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
ginkgo_tools-0.1.5.tar.gz
(10.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ginkgo_tools-0.1.5.tar.gz.
File metadata
- Download URL: ginkgo_tools-0.1.5.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a19d9c4cbff7d2e8e3776403b2ee87096ea6df567591cdc41864d94079024aa4
|
|
| MD5 |
7f3c01a10eb8f2a6e8683a489d604b9e
|
|
| BLAKE2b-256 |
5dc37d06e7afe961e3cfdfe939c696c9aba4787f3a9f2bbab92d5f6082ea58e6
|
File details
Details for the file ginkgo_tools-0.1.5-py3-none-any.whl.
File metadata
- Download URL: ginkgo_tools-0.1.5-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33812cdf5c3a4fd2a7e8abb5e9a95f80db75db343b5a62b8c9f207b02a19efff
|
|
| MD5 |
e0298f8109ae9bf43754d75909e87944
|
|
| BLAKE2b-256 |
03aa926049ec005b6cad476a358aa3a6e3f6d7d33cc7bf9f536b64799ccccbef
|