
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
pythontk
Advanced tools
*A collection of Python utility functions for file operations, text processing, and basic image/video manipulation. Provides helper classes and convenience functions for common programming tasks.*
A collection of Python utility functions for file operations, text processing, and basic image/video manipulation. Provides helper classes and convenience functions for common programming tasks.
pythontk provides utility functions organized into focused modules:
Python Requirements:
Installation:
pip install pythontk
Development Installation:
git clone https://github.com/m3trik/pythontk.git
cd pythontk
pip install -e .
Optional Dependencies:
PIL (Pillow) for image operationsnumpy for mathematical operationsFFmpeg for video utilitiesimport pythontk as ptk
# Get directory contents with filtering
files = ptk.filter_list(
ptk.get_dir_contents('/path/to/directory'),
inc=['*.py', '*.txt'], exc='*temp*'
)
# Path formatting
clean_path = ptk.format_path('/path\\to/file.txt', style='forward')
# String sanitization
clean_name = ptk.sanitize('My Asset Name!@#', replacement_char='_')
# Result: 'My_Asset_Name'
# Text formatting
formatted = ptk.format_string('hello world', style='title')
# Result: 'Hello World'
# Requires PIL/Pillow
from pythontk import ImgUtils
# Create image from channels
img = ImgUtils.pack_channels({
'R': red_channel_path,
'G': green_channel_path,
'B': blue_channel_path
})
# Get image dimensions
width, height = ImgUtils.get_image_size('image.jpg')
# Filter lists and dictionaries
filtered_data = ptk.filter_dict(
data, inc=['name', 'version'], keys=True
)
# List filtering with patterns
python_files = ptk.filter_list(
file_list, inc=['*.py'], exc=['*test*']
)
core_utils)Basic helper classes and decorators:
HelpMixin: Documentation helpercached_property: Property caching decorator@listify: Convert returns to listsfile_utils)File system operations:
get_dir_contents(): Directory listing with filteringget_file_contents(): Read file contentscreate_dir(): Directory creationformat_path(): Path formattingstr_utils)Text processing functions:
sanitize(): Clean strings for filenamesformat_string(): Text case formattingremove_chars(): Character removalimg_utils)Basic image operations (requires PIL):
get_image_size(): Get image dimensionspack_channels(): Combine image channelsget_channels(): Extract image channelsvid_utils)Simple video operations (requires FFmpeg):
extract_frames(): Extract video framesget_video_info(): Video metadatamath_utils)Mathematical helper functions for common calculations.
pythontk uses a dynamic attribute resolution system allowing direct access to utility functions:
import pythontk as ptk
# These are equivalent:
ptk.sanitize('text') # Direct access
ptk.str_utils.sanitize('text') # Module-specific access
This is a utility collection for common Python tasks. Contributions that add useful, focused utility functions are welcome.
This project is licensed under the MIT License.
FAQs
*A collection of Python utility functions for file operations, text processing, and basic image/video manipulation. Provides helper classes and convenience functions for common programming tasks.*
We found that pythontk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.