Python utils
Tested in Python2.7, Python3.4.
callit
You can do:
from __future__ import print_function
print('x', 'y', sep=',')
But I can not do:
from __future__ import print_function
parameters = ('x', 'y', sep=',')
print(parameters)
With callit, I can do similar thing:
from __future__ import print_function
from yxpy.callit import CallIt
parameters = CallIt('x', 'y', sep=',')
parameters(print)
Sometimes, you may use Parameters(similar to CallIt):
from __future__ import print_function
from yxpy.callit import Parameters
parameters = Parameters('x', 'y', sep=',')
parameters(format)
dotit
Usually, dictionary can be used like this:
d = dict(a=1) d['b'] = 2 x = d['a'] + d['b']
The members in dictionary can only be accessed by [], But in some other languages(eg. javascript), they can be access by .:
d.b = 2 x = d.a + d.b
With dotit, you can do same thing in similar manner, dotit provide thress class to do it.
DotDict:
from dotit import DotDict d = DotDict(a=1) d.b = 2 x = d.a + d.b
DotOrderedDict, inherit from collections.OrderedDict:
... # similar to DotDict
DotIt, if you already have a dict like object, you can wrapper with DotIt:
d = dict(a=1, b=2) ... d = DotIt(d) x = d.a + d.b
DotIt can also deal with nest dict:
d = dict(a=dict(aa=1, ab=2), b=2) ... d = DotIt(d) x = d.a.aa + d.a.ab
loadit
Load or reload python object
import module:
import loadit
load moudule:
mod = loadit.load_it('mymodule')
load function:
func = loadit.load_it('mymodule.func')
load class:
MyClass = loadit.load_it('mymodule.MyClass')
reload module:
new_mod = loadit.reload_it(mod)
reload function:
new_func = loadit.reload_it(func)
reload class:
NewMyClass = loadit.reload_it(MyClass)
yamlfile
load config from YAML file, add a include tag.
main.yaml:
a: !include a.yaml
a.yaml:
name: a
usage:
from yxpy import yamlfile
yamlfile.load('main.yaml')
logginghandlers
SocketHandler(host, port)
DatagramHandler(host, port)
RedisListHandler(list_name, list_maxsize=1024, host=’localhost’, port=6379, password=None)
RedisPublishHandler(self, channel, host=’localhost’, port=6379, password=None)
SocketHandler & DatagramHandler
logging package provide many Handlers, include SocketHandler and DatagramHandler, but the data transmit to server is packed as binary, this module privide simular handler to transmit plain text to server.
example:
socket_handler = SocketHandler(host, port) ... datagram_handler = DatagramHandler(host, port) ...
RedisListHandler & RedisPublishHandler
use Redis as log server, the two handler is just privide a singleway to redis server. to keep simple, the handlers does check the response of redis.
example:
handler = RedisListHandler(list_name=’logtest’, list_maxsize=100, password=’test’) … handler = RedisPublishHandler(channel=’logtest’, password=’test’) …
Changes
0.1.5(2014-10-11)
refactoring: import statement in reloadit
0.1.3(2014-09-26)
DotIt support nest dict.
0.1.2(2014-09-26)
add dotit: include DotIt, DotDict, DotOrderedDict
0.1.1(2014-09-19)
add logginghandlers: - SocketHandler - DatagramHandler - RedisListHandler - RedisPublishHandler
0.1.0(2014-09-18)
callit
loadit
yamlfile
Metadata
Release files for yxpy 0.1.5
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 |
|---|---|---|---|---|
| yxpy-0.1.5.zip | 10.1 kB | Without provenance | Details for yxpy-0.1.5.zip |
Release files / yxpy-0.1.5.zip
| Download URL | yxpy-0.1.5.zip |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f0f5d5734954e37a03987aa25bcb7aae38a50425003746cc514df1a769163b3
|
|
BLAKE2b-256 checksum How to use checksums |
c68a0b98856f042d3f41707d25d1746bc11fbde3335c1afb820b7f4479b8ca12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for yxpy 0.1.5
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.