Skip to content

A collection of Python utilities ported from the R ecosystem.

License

Notifications You must be signed in to change notification settings

tonkintaylor/ruru

Repository files navigation

ruru

ruru

PyPI Version uv Ruff usethis

A collection of Python utilities ported from the R ecosystem.

Features

base module

The ruru.base module provides core utilities:

  • match_arg: A Python equivalent of R's match.arg function for verifying function arguments against a set of valid options. Recommended usage:
from ruru.base import match_arg

user_choice = "apple"
available_choices = ["Apple", "Banana", "Cherry"]

# Normalize user input before passing it to match_arg.
# Which transformation to use depends on the style of available_choices:
#   - .title() if choices look like "Apple"
#   - .upper() if choices look like "APPLE"
#   - .lower() if choices look like "apple"

user_choice = match_arg(user_choice.title(), available_choices)
  • pmatch: A Python equivalent of R's pmatch function for finding partial substring matches against a set of reference strings.

Inspired by the R base package.

config module

The ruru.config module gives an easy way to manage of configuration settings in Python applications via YAML files.

Recommended usage:

from importlib.resources import files
from ruru import config

config_path = files("<mypkg>.cli").joinpath("config.yml") 
config_dict = config.get(file = config_path)

Inspired by the R config package.

cli module

The ruru.cli module provides utilities for enhanced command-line interface output, including colored text, formatted headings, alert messages, and bullet-point lists.

Recommended usage:

from ruru import cli
cli.h1("Heading")
cli.alert("This is an alert message")

Inspired by the R cli package.

About

A collection of Python utilities ported from the R ecosystem.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •