Python utils
Project description
Python Utilities
================
Python 编程工具集,本着实用、简单的原则,尽量减少对其他模块的依赖。
由于内容比较杂,所以并不过分追求兼容性。
pu.aio
------
asyncio 相关扩展和工具。
pu.aio.util
- file_get_contents: 读取文件内容或下载 http 页面内容
pu.aio.timer
~~~~~~~~~~~~
提供一个简单的 Timer。
- class Timer
pu.aio.client
~~~~~~~~~~~~~
简单的 Client 类和支持重连的 ReconnectingClient
- class Client
- class ReconnectingClient
pu.aio.dummyprotocol
~~~~~~~~~~~~~~~~~~~~~~
支持动态协议识别,根据收到的数据判断连接实际采用的协议。
- class DummyProtocolFactory
- class DummyProtocol
pu.aio.virtualprotocol
~~~~~~~~~~~~~~~~~~~~~~
!! 请使用 dummyprotocol
支持动态协议识别,根据收到的数据判断连接实际采用的协议,动态协议需要继承自 RealProtocol。
- class VirtualProtocolFactory
- class VirtualProtocol
- class RealProtocol
pu.util
----
- shorten
pu.dictutil
-----------
- repr_dict
- Dot
- DotDict
- OrderedDict
- DotOrderedDict
pu.manager
----------
- class Manager: 对象管理器
用法::
manager = Manager()
manager.register(1, 'ONE')
@manager.register
def a(): pass
@manager.named('funcb', 'FUNCB')
def b(): pass
@manager.register
class A: pass
@manager.named('clsb', 'CLSB')
class B: pass
pu.datatype
-----------
自定义数据类型
- class pretty_bytes -- 支持 hex 格式
示例::
pb = pretty_bytes(b'\xaa\xbb')
assert '{0:hex}'.format(pb) == 'aabb'
pu.pcap
-------
网络抓包工具
命令行用法::
python -m pu.pcap # Windows/Linux
python -m pu.pcap eth1 # Linux
python -m pu.pcap lo # Linux
python -m pu.pcap 192.168.0.100 # Windows
程序中的用法::
from pu.pcap import pcap
for packet in pcap('eth1'):
print(packet)
0.6.0(2014-11-06)
-----------------
- 添加 class pu.datatype.pretty_bytes
- pu.pcap: 网络抓包工具
0.5.5(2014-11-01)
-----------------
- pu.util.bytes_fromhex: 允许比 bytes.fromhex 更宽松的输入
0.5.4(2014-11-01)
-----------------
- BUGFIX: pu.aio.timer.Timer 添加类成员 __timer
0.5.3(2014-11-01)
-----------------
- 添加 pu.aio.util.file_get_contents
0.5.2(2014-10-31)
-----------------
- dictutil: Dot 增加 __contains__
0.5.1(2014-10-31)
-----------------
- dictutil: 改进 Dot 的 __repr__ 和 __str__
0.5.0(2014-10-31)
-----------------
- 增加 dummyprotocol, 取代 virtualprotocol
0.4.4(2014-10-30)
-----------------
- aio 中各个模块采用自己的 logger
0.4.3(2014-10-30)
-----------------
- dictutil.Dot: 添加 get 和 setdefault 方法
0.4.3(2014-10-30)
-----------------
- client.Client: 修改 connect 方法为 coroutine
- 版本: Alpha 改为 Beta
0.4.2(2014-10-29)
-----------------
- 允许指定 yaml 文件编码(缺省为 utf-8)
0.4.1(2014-10-29)
-----------------
- virtualprotocol: 允许指定缺省协议,去除原来一个应用只能使用一个虚拟协议的限制
0.4.0(2014-10-28)
-----------------
- 添加 manager 模块
0.3.2(2014-10-27)
-----------------
- BUGFIX: dictutil.Dot 应该支持 [key] 方式访问
0.3.1(2014-10-27)
-----------------
- 完善软件包版本信息
0.3.0(2014-10-26)
-----------------
- dictutil -- repr_dict, Dot, DotDict, OrderedDict, DotOrderedDict
0.2.0(2014-10-25)
-----------------
- yamlfile -- add !include tag
0.1.1(2014-10-25)
-----------------
- Add MANIFEST.in
0.1.0(2014-10-25)
-----------------
- pu.aio.client
- pu.aio.timer
- pu.aio.virtualprotocol
- pu.util.shorten
================
Python 编程工具集,本着实用、简单的原则,尽量减少对其他模块的依赖。
由于内容比较杂,所以并不过分追求兼容性。
pu.aio
------
asyncio 相关扩展和工具。
pu.aio.util
- file_get_contents: 读取文件内容或下载 http 页面内容
pu.aio.timer
~~~~~~~~~~~~
提供一个简单的 Timer。
- class Timer
pu.aio.client
~~~~~~~~~~~~~
简单的 Client 类和支持重连的 ReconnectingClient
- class Client
- class ReconnectingClient
pu.aio.dummyprotocol
~~~~~~~~~~~~~~~~~~~~~~
支持动态协议识别,根据收到的数据判断连接实际采用的协议。
- class DummyProtocolFactory
- class DummyProtocol
pu.aio.virtualprotocol
~~~~~~~~~~~~~~~~~~~~~~
!! 请使用 dummyprotocol
支持动态协议识别,根据收到的数据判断连接实际采用的协议,动态协议需要继承自 RealProtocol。
- class VirtualProtocolFactory
- class VirtualProtocol
- class RealProtocol
pu.util
----
- shorten
pu.dictutil
-----------
- repr_dict
- Dot
- DotDict
- OrderedDict
- DotOrderedDict
pu.manager
----------
- class Manager: 对象管理器
用法::
manager = Manager()
manager.register(1, 'ONE')
@manager.register
def a(): pass
@manager.named('funcb', 'FUNCB')
def b(): pass
@manager.register
class A: pass
@manager.named('clsb', 'CLSB')
class B: pass
pu.datatype
-----------
自定义数据类型
- class pretty_bytes -- 支持 hex 格式
示例::
pb = pretty_bytes(b'\xaa\xbb')
assert '{0:hex}'.format(pb) == 'aabb'
pu.pcap
-------
网络抓包工具
命令行用法::
python -m pu.pcap # Windows/Linux
python -m pu.pcap eth1 # Linux
python -m pu.pcap lo # Linux
python -m pu.pcap 192.168.0.100 # Windows
程序中的用法::
from pu.pcap import pcap
for packet in pcap('eth1'):
print(packet)
0.6.0(2014-11-06)
-----------------
- 添加 class pu.datatype.pretty_bytes
- pu.pcap: 网络抓包工具
0.5.5(2014-11-01)
-----------------
- pu.util.bytes_fromhex: 允许比 bytes.fromhex 更宽松的输入
0.5.4(2014-11-01)
-----------------
- BUGFIX: pu.aio.timer.Timer 添加类成员 __timer
0.5.3(2014-11-01)
-----------------
- 添加 pu.aio.util.file_get_contents
0.5.2(2014-10-31)
-----------------
- dictutil: Dot 增加 __contains__
0.5.1(2014-10-31)
-----------------
- dictutil: 改进 Dot 的 __repr__ 和 __str__
0.5.0(2014-10-31)
-----------------
- 增加 dummyprotocol, 取代 virtualprotocol
0.4.4(2014-10-30)
-----------------
- aio 中各个模块采用自己的 logger
0.4.3(2014-10-30)
-----------------
- dictutil.Dot: 添加 get 和 setdefault 方法
0.4.3(2014-10-30)
-----------------
- client.Client: 修改 connect 方法为 coroutine
- 版本: Alpha 改为 Beta
0.4.2(2014-10-29)
-----------------
- 允许指定 yaml 文件编码(缺省为 utf-8)
0.4.1(2014-10-29)
-----------------
- virtualprotocol: 允许指定缺省协议,去除原来一个应用只能使用一个虚拟协议的限制
0.4.0(2014-10-28)
-----------------
- 添加 manager 模块
0.3.2(2014-10-27)
-----------------
- BUGFIX: dictutil.Dot 应该支持 [key] 方式访问
0.3.1(2014-10-27)
-----------------
- 完善软件包版本信息
0.3.0(2014-10-26)
-----------------
- dictutil -- repr_dict, Dot, DotDict, OrderedDict, DotOrderedDict
0.2.0(2014-10-25)
-----------------
- yamlfile -- add !include tag
0.1.1(2014-10-25)
-----------------
- Add MANIFEST.in
0.1.0(2014-10-25)
-----------------
- pu.aio.client
- pu.aio.timer
- pu.aio.virtualprotocol
- pu.util.shorten
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
pu-0.6.0.zip
(15.6 kB
view hashes)