A collection of self dev py library
Project description
A collection of self dev library.
file_changes_xh
In case we have log file from apache web server, the log file name is "access.log", the log will be renamed to "access.log-{YYYYmmdd}" daily.
The configuration can be done as below to capture the all the log file content even after renamed to new file name.
import file_changes_xh as fc
import datetime as dt
fileName = "access.log"
# Please see the RenameHandler source code for detail
# The return value for getFunction() is callable for f"{fileName}{separator}{date}"
renameStrategy = fc.RenameHandler(date=dt.date.today(), separator="-")
fpu = fc.FileProgressUtils() # create the file progress utils
gen = fpu.checkOnceAndDo(
fileName,
renameStrategy.getFunction()
)
while True:
try:
dr = next(gen)
if dr.deltaType == fc.DeltaType.RENAMED:
pass
else:
# handler that simply print out the data
# should implement the own handling logic
fc.ChangeHandler.print_changes(dr)
except StopIteration:
pass
ip_utils_xh
IPv4 string handling utils
import ip_utils_xh as ipu
# convert string "192.168.8.1/16" to ipu.Ip object
ip = ipu.Ip.from_regular_form("192.168.8.1/16")
print(ip.binary_notation()) # print in binary format
ipResults = [
print(f"{ipStr}[{pow(2, 32 - ip.ip_seg[4])}] {ip.binary_notation()}")
for ipStr in
"10.91.132.0/22\n10.91.136.0/21\n10.91.144.0/20\n10.91.160.0/19\n10.91.196.0/22\n10.91.200.0/21\n10.91.208.0/20\n10.91.224.0/19".split("\n")
for ip in [ipu.Ip.from_regular_form(ipStr)]
]
Find host by ip if applicable
form ip_utils_xh import defaultIpHostFinder as ipHostFinder
ipHostFinder.find("127.0.0.1")
string_utils_xh
import string_utils_xh as su
su.repeat_str()
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
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 pyXhUtils-0.0.8.tar.gz.
File metadata
- Download URL: pyXhUtils-0.0.8.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9e21835a3a6c5680ad6b2cb1ab5748a2b012ef191982f29c63da89ce6aae930
|
|
| MD5 |
0442da687187ad96b6accfae67cd324a
|
|
| BLAKE2b-256 |
e126a04d6e6ef4876896f591259b8f4a0832c7f74f85880670cf5f6dcd275ab9
|
File details
Details for the file pyXhUtils-0.0.8-py3-none-any.whl.
File metadata
- Download URL: pyXhUtils-0.0.8-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba391a875ba8e88f3a1c1e62bddfc5df8c281969c5a349415b8523e5b2e2a3c3
|
|
| MD5 |
de6806c25afbc3634d1a25aaba820021
|
|
| BLAKE2b-256 |
675d5d93c24549077ced93a7965583d3bb49c9a7de2326d9305c19061fc0ecd6
|