Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Wrap common Python utilities for working with files, git, ZIP, lists, processes, dates and times.
A small library wrapping common Python utilities for working with files, git, ZIP, lists, processes, dates and times.
Functions that I find myself writing time and again, on various OSS and personal projects - so collecting in one place, in case it is of use!
For more details, see the documentation.
python -m pip install --upgrade cornsnake
pip install PyMuPDF
Functions are organised in modules, providing logical groups like util_file
or util_print
.
To use a particular module, simply import it from cornsnake:
from cornsnake import util_file, util_print
Then, the modules are available to use:
lines = util_file.read_lines_from_file("my-file.txt")
util_print.print_result(f"Read {len(lines)} lines")
To see what functions are available, see the Documentation or source code.
For examples see the unit tests and e2e tests.
Module | Description | Documentation |
---|---|---|
config | Globally accessible config object. Can be configured by for example reading from command line arguments or TOML file (via tomllib), and then writing to the properties in-memory. See util_toml.py for an example of reading from an ini file (TOML format). | config docs |
util_color | Defines color constants and a function for colorizing text output for terminal. | util_color docs |
util_date | Functions for date manipulation. It includes functions to parse, format, add days to, and validate dates in the yyyy-mm-dd format. | util_date docs |
util_dependencies | Functions for checking the versions of Python and Git. It ensures that the major and minor versions of these dependencies meet the required criteria. | util_dependencies docs |
util_dir | Working with directories, files, and file paths. | util_dir docs |
util_file | File operations including copying, reading, and writing text to files. | util_file docs |
util_git | Functions for interacting with a Git repository. It includes functions for executing Git commands, checking out branches, handling commits, and managing Git configuration settings. | util_git docs |
util_input | Functions for handling user input with various formats and validations. | util_input docs |
util_json | Functions for reading from and writing to a JSON file. The read_from_json_file function reads JSON data from a file, and the write_to_json_file function writes JSON data to a file. | util_json docs |
util_list | Functions for manipulating lists of data. Functions include chunking lists, excluding elements from one list that are present in another, finding the intersection of two lists, and various other list operations. | util_list docs |
util_log | Functions for logging exceptions and setting up logging configurations. | util_log docs |
util_markdown_table | Generating Markdown content. Functions like adding row separators, generating Markdown images, and generating italicized text are included. | util_markdown_table docs |
util_network | Making a POST request using the urllib library. | util_network docs |
util_object | Functions for working with object attributes. The get_attributes function retrieves all non-private attributes of an object. The get_attribute_value function returns the value of a specific attribute of an object. | util_object docs |
util_os | Functions for checking the operating system and logging OS information. The functions determine if the OS is Windows, Mac, or Unix, and log relevant OS details. | util_os docs |
util_pdf | Functions for extracting text from a PDF file and checking if a file is a PDF. | util_pdf docs |
util_pick | Functions for randomly selecting text. The pick_one_random function chooses a random text from a list. The pick_one_by_prompt function prompts the user to pick a text from a list. | util_pick docs |
util_print | A Single entry point for printing - so can add custom printing with color and logging. Functions for printing with different colors, logging messages, printing sections, and handling warnings. | util_print docs |
util_proc | Running processes and opening Windows Explorer at a specified directory. | util_proc docs |
util_progress | Functions for tracking progress and updating a progress bar. | util_progress docs |
util_robust_delete | Functions for recursively deleting directories and their contents. | util_robust_delete docs |
util_string | Check if a text string is empty. The is_empty function checks if a text string is None or contains only whitespace or a hyphen. | util_string docs |
util_text | Defines text constant variables - including for line endings. | util_text docs |
util_toml | Reading TOML (ini) files and updating the global config in memory (from config.py). | util_toml docs |
util_validate | Functions for checking and validating configuration settings in the config.py file. | util_validate docs |
util_wait | Function for waiting for a specified number of seconds. The wait_seconds function pauses the program execution for the specified number of seconds. | util_wait docs |
zip_dir | Function for creating a zip archive from a directory. The create_zip function creates a zip archive of a specified directory. | zip_dir docs |
FAQs
Wrap common Python utilities for working with files, git, ZIP, lists, processes, dates and times.
We found that cornsnake 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.