PyCFUtils (Cristi Fati's Utils for Python (&& more)) - a collection of goodies ((cool) scripts / utilities)
Project description
PyCFUtils
PyCFUtils (Cristi Fati's Utils for Python (&& more)) - a collection of goodies ((cool) scripts / utilities)
Install
Use PIP:
python -m pip install --upgrade pycfutils
Usage example
import os
import time
import pycfutils.io
import pycfutils.miscellaneous as misc
import pycfutils.network
import pycfutils.system
from pycfutils.exceptions import ModuleException, NetworkException
print("Press a key in less than one second...")
print(pycfutils.io.read_key(timeout=1))
print(misc.timestamp_string(human_readable=True, separator="T", microseconds=True))
print(tuple(misc.progression(ratio=2)))
print(misc.merge_dicts({1: 2}, misc.nest_object((1,), 3)), misc.nested_dict_item({1: {2: 3}}, (1, 2)))
print(misc.randomize(180, round_result=True))
print(misc.call_stack())
misc.pretty_print(
tuple(
misc.process_path_items(
path="${a_directory_with_few_child_items}",
processor=lambda arg: os.stat(arg).st_size,
)
),
head="Path items:",
tail="",
)
@misc.timed_execution()
def func(arg0, kw0=1):
time.sleep(0.2)
return 5
func("123")
try:
print(pycfutils.network.connect_to_server("127.0.0.1", 22))
except NetworkException as e:
print(e)
pycfutils.system.cpu_stress(3)
# --- Requires PyGObject (also might take some time to complete) ---
try:
from pycfutils.gstreamer import RegistryAccess
except ModuleException as e:
print(e)
else:
ra = RegistryAccess()
print(ra.element_classes())
# --- Windows only ---
import pycfutils.gui
print(pycfutils.gui.message_box("Title", "Text to display", x=320, y=200))
Functionality to build a *.dll (*.so) with SetupTools. Parts of setup.py:
from setuptools import setup
from pycfutils.setup.command.build_clibdll import build_clibdll
from pycfutils.setup.command.install_platlib import install_platlib # Optional
dll = (
"dll_name",
{
"sources": ["src0.c", "src1.c", ],
# ...
"dll": True, # False (or nothing) for regular (static) library
"copy_files": { # Optional (copy artifacts)
"dll_name.so": "pkg_name", # dll_name.dll on Win
}
# ...
},
)
setup(
name="pkg_name",
# ...
cmdclass={
"build_clib": build_clibdll,
"install": install_platlib,
},
libraries=[dll],
# ...
)
There are also some useful (CLI wrapper) scripts in the tools folder. Example:
-
Nix:
ls "pycfutils/tools" for script in $(find "pycfutils/tools" -maxdepth 1 -type f); do python "${script}" -h; done
-
Win:
dir /b "pycfutils\tools" for /f %g in ('dir /b /a-d /a-l "pycfutils\tools\*.py"') do (python "pycfutils\tools\%g" -h)
Or run them as modules (e.g. in 2 separate terminals). Example (Shell snippets that also work in Batch):
-
Terminal 1:
python -m pycfutils.tools.connect_to_server -a 127.0.0.1 -p 16180 # Go to the other terminal and run the other command (start the server), then come back and re-run the previous command python -m pycfutils.tools.connect_to_server -a 127.0.0.1 -p 16180
-
Terminal 2:
python -m pycfutils.tools.start_server -a 127.0.0.1 -p 16180
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 Distributions
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 pycfutils-2025.11.29.tar.gz.
File metadata
- Download URL: pycfutils-2025.11.29.tar.gz
- Upload date:
- Size: 38.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16d6f6970903fce37fa2756777665f2d56a66144465796baa18e4079deebc0a8
|
|
| MD5 |
178ba18c269e21c46354307953cbba92
|
|
| BLAKE2b-256 |
b3e8d92e095c517f89d867e87a414cd7f686aaface2457b0692fa9683e652ecd
|
File details
Details for the file pycfutils-2025.11.29-py3-none-win_amd64.whl.
File metadata
- Download URL: pycfutils-2025.11.29-py3-none-win_amd64.whl
- Upload date:
- Size: 47.7 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be1b58f717a1606b05d334217dd3e161d6e91576d2b1815dcef19f73d9493a2d
|
|
| MD5 |
2a0f429f598ce7bc9618e4768e9e3dbb
|
|
| BLAKE2b-256 |
e811fc42b4a09505c33a5a3e575d45d0e03e04be4ab9271ca6d4499af09ccd97
|
File details
Details for the file pycfutils-2025.11.29-py3-none-win32.whl.
File metadata
- Download URL: pycfutils-2025.11.29-py3-none-win32.whl
- Upload date:
- Size: 47.3 kB
- Tags: Python 3, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1e1d2c09ab15c352e3524e8944b029b634f608e68656d6b902d3600e7a6a2bb
|
|
| MD5 |
d304a5909b81c999ffc1299bb5683a9e
|
|
| BLAKE2b-256 |
8cc11de3219ee149919a47c2f676b745a10e36ace9538319c815ead2f4a554e9
|
File details
Details for the file pycfutils-2025.11.29-py3-none-any.whl.
File metadata
- Download URL: pycfutils-2025.11.29-py3-none-any.whl
- Upload date:
- Size: 47.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1933ff6b7cb0b28320deb48e4839201d5e7be3c0f33a87c4fcbd6e59a743600
|
|
| MD5 |
57a7928e8a3880ba02ef717ba141b648
|
|
| BLAKE2b-256 |
a18ce12b7cb64967930b545ae4c940baf0664008b1ecb2e50a6d34996ef2af63
|