Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

FrittoMisto 🍟


Welcome to FrittoMisto, a Python module with a Fried Mix of utilities to enhance your day to day coding experience.

Please note that FrittoMisto is currently at its very verge and not thoroughly tested. We invite you to explore, experiment, share your feedback or, even better, contribute! 👩‍🍳



🍤 Features / Philosophy

If you frequently develop Python tools, you might have experienced the repetition of using similar utilities or helpers across various applications. FrittoMisto was born out of my desire to consolidate these commonly used tools into a single swiss army knife. Now, I can effortlessly import and reuse them whenever necessary.

  • Mix of Utilities: FrittoMisto serves up a diverse array of utilities, ranging from string manipulation to system interactions.

  • Simplicity: Enjoy the simplicity and ease of use that FrittoMisto brings to your projects. FrittoMisto utilities are designed to be intuitive and require minimal code to achieve common tasks.

🍳 Installation

Install FrittoMisto using pip: pip install frittomisto

🍽️ Usage

Whet your appetite with a quick sample of FrittoMisto in action:

from frittomisto.path import cd

with cd("/temporarily/move/here"):
  # do some stuff 

🍲 Documentation

Path module

Utilities for paths and file system operations.

cd context manager

A context manager to temporarily move to a directory.

from pathlib import Path
from frittomisto.path import cd

with cd("/path/to/dir"):
  print(Path.cwd()) # temporarely moved to "/path/to/dir"

sanitize_path

An utility to sanitize untrusted paths.

from frittomisto.path import sanitize_path

# Throws a ValueError exception if path is not within allowed_dir 
sanitize_path("/path/to/dir", "/path/to/allowed/dir")

# Returns normalized absolude path if path is within allowed_dir
sanitize_path("/path/../to/dir", "/path/") # returns "/path/dir"

Async module

Mix of asyncio utilities.

make_sync

A simple decorator to transform any async function into an sync function.

from frittomisto.asyncio import make_sync

@make_sync
async def an_async_function():
  ...

def a_sync_function():
  # The async function is now a sync function
  an_async_function()

Profiling module

pp utils

The profiling module offers a set of simple functions to manage multiple perf counters:

  • pp_start(name) starts a new counter named name
  • pp_stop(name) stops the counter name
  • pp_get(name) gets stat info of the counter name
  • pp_stats() pretty print stats for all counters
from frittomisto.profiling import pp_start, pp_stop, pp_stats

pp_start("outer")
  for i in range(10):
    pp_start("func1")
    func1()
    pp_stop("func1")
    if i % 2 == 0:
      pp_start("func2")
      func2()
      pp_stop("func2")

pp_stop("outer")
pp_stats()

# This will show perf stats in a table format:
# PID    | Name  | tot_time           | rounds | avg_time            | max_time
# 169003 | outer | 5.679527849017177  | 1      | 5.679527849017177   | 5.679527849017177
# 169003 | func1 | 4.06138202897273   | 10     | 0.406138202897273   | 0.8546963339904323
# 169003 | func2 | 1.6178952640620992 | 5      | 0.32357905281241983 | 0.46843800198985264

Config module

Utilities to manage your project configs.

cfg

The global instance of the program's config.

import os
from pathlib import Path
from frittomisto.cfg import cfg
 with open(str(Path.cwd() / "frittomisto.toml"), "w", encoding="utf-8") as f:
  f.write(
    """
    [foo]
    bar = "hello"
    """
)

os.chdir("subdir") # configs are searched in all parent dirs
print(cfg["foo"]["bar"]) # prints hello

IO module

no_print

Context manager to disable all calls to print

from frittomisto.io import no_print

with no_print():
  print("hello") # does nothing

Logging module

Logging utils.

get_logger

Get a named logger.

from frittomisto.logging import get_logger

log = get_logger("my logger")
log.error("error message") # logs an error

log_level

Context manager to temporarily change log level.

from frittomisto.logging import get_logger, log_level

with log_level("DEBUG"):
  log = get_logger("my logger")
  log.debug("debug message") # the debug message will be shown

URL module

Utilities to work with URLs

extract_urls

Scan text for urls.

from frittomisto.url import extract_urls
text = "My URL is http://example.com"
urls = extract_urls(text)
print(urls[0]) # http://example.com

👨‍🍳 Contributing

Craving more features or found a bug in our recipe? Contribute to FrittoMisto by opening an issue or submitting a pull request. Your contributions make the mix even more delightful!

License

FrittoMisto is released under the MIT License.


Release files for frittomisto 0.0a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for frittomisto 0.0a2
File Size Uploaded
frittomisto-0.0a2.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for frittomisto 0.0a2
File Interpreter ABI Platform
frittomisto-0.0a2-py3-none-any.whl Python 3 none any Details

Total release size: 20.8 kB

Release files / frittomisto-0.0a2.tar.gz

Download URL frittomisto-0.0a2.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
866b5968dc1035de22d78ce66419ab2d6725bed62bb7e23e72e6fc257febf133
BLAKE2b-256 checksum
How to use checksums
3ab4c9099a04e23cbb5629e4d15f7d1e07f0354fd6f01a0ac125aa31990e855b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / frittomisto-0.0a2-py3-none-any.whl

Download URL frittomisto-0.0a2-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c6686021309bef1658d0b0b7f8a05c24a539d0ba5388a13e38b85a03a9e2028
BLAKE2b-256 checksum
How to use checksums
f8cf0184df64b9845639fce2e53e95b5ded70e5945ba3c8ef0394a4883c26a41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.0a2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page