mwutils
maxwin 团队开发框架utils
为了兼容windows开发环境,日期时间parse模块采用python-dateutil,但ciso8601的pars性能比之快百倍,如果是linux下安装,请先安装
“pip install ciso8601”
安装
$ pip install mwutils
mw_time.py 单元
from mwutils.mw_time import *
# 字符串转为本地日期时间
print(str2datetime('2018-01-01'))
print(str2datetime('2018-01-01T12:00:00'))
print(str2datetime('2018-01-01T12:00:00Z'))
print(str2datetime('2018-01-01T12:00:00+02:00'))
# 字符串转日期
print(str2date('2018-01-01'))
# 字符串转时间
print(str2time('11:11:11'))
# 日期时间转iso8601 tz 格式字符串
print(datetime2isostr(datetime.now()))
# 日期时间转本地日期时间字符串
print(datetime2str(datetime.now()))
# 日期时间转integer时间戳
print(datetime2timestamp(datetime.now()))
# 时间戳转本地日期时间
print(timestamp2datetimestr(1515579120.0))
# get locale timezone
print(get_locale_timezone())
# min_time(dt1,dt2),max_time(dt1,dt2) 两个日期时间取最小和最大时间
utils.py 单元
from mwutils.utils import getConfig,hostname
# 读取config.ini
print(getConfig('./config.ini')
# 获取电脑的 hostname
print(hostname)
mw_consul.py 单元
> 访问consul 中的常用服务配置
from mw_consul import *
# reg_service : 向consul中注册服务
# dereg_service: 注销服务
# AgentConf() : 獲取本機agent
# RedisConf() : redis的配置
# RedisConfMaster(): master redis的配置
# RedisConfSlave():离本机最近的slave redis 配置
# DatabaseConf('maxbus'):获取tag=maxbus的database服务的配置
# KongConf():取kong的配置
# KongAdminConf():取kong admin 的配置
# KafkaConf():取kafka的配置
# Cassandra():取Cassandra的配置
# ServiceConf(service_name,tag):取设定tag,service_name的服务配置
cache.py 单元
> sigleton,内存中只会创建一个实例
from cache import Cached
# # Example
class Spam(metaclass=Cached):
def __init__(self, name):
print('Creating Spam({!r})'.format(name))
self.name = name
sendemail.py 单元
> 发送邮件
from sendemail import Emailsender
Changes
0.1.42
允许DatabaseConf db URI 支持pyodbc
0.1.41
允许KongConf 按tag 从consul中载入kong配置
0.1.39
DatabaseConf增加判断是否db_have_changed
0.1.33
Redis 配置支持哨兵模式
0.1.30
解决linux 下 str2datetime(‘20201009101112’) 会报错的问题
0.1.29
windows下用dateutil做时间字串parse
0.1.28
修正从consul的kv中取redis db 失败的问题
0.1.27 (2018-12-19)
重整mw_consul单元的类
0.1.24 (2018-10-31)
解决非Unicode中文环境下不能安装的问题
0.1.23 (2018-10-29)
在mw_time单元中增加对iso6801日期时间的支持,增加了部分常用日期时间的处理
删除 register_kong.py
Metadata
Release files for mwutils 0.1.46
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mwutils-0.1.46.tar.gz | 14.9 kB | Without provenance | Details for mwutils-0.1.46.tar.gz |
Release files / mwutils-0.1.46.tar.gz
| Download URL | mwutils-0.1.46.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e005c2435aaa8053e9df7987256412a75d5445163f1aea2cbc379d2afb3b184
|
|
BLAKE2b-256 checksum How to use checksums |
24342d1bc015fa163ecc5c685973015ed35d3f97e4c15fa4a6c4a6a9679ad0b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for mwutils 0.1.46
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.