API Reference
This page contains the documentation and usage examples for all modules inside rowanqol.
Input Utilities (inputs)
Functions designed to handle terminal user inputs safely by automatically catching errors and forcing clean loops.
int_input(prompt, error_msg="Enter an integer.")
Safely captures an integer from the command line.
* Arguments:
* prompt (str): The text message shown to the user.
* error_msg (str): What to print if they type letters or invalid characters.
* Returns: int
float_input(prompt, error_msg="Enter a float.")
Safely captures a floating-point (decimal) number from the command line.
* Arguments:
* prompt (str): The text message shown to the user.
* error_msg (str): What to print if they type invalid characters.
* Returns: float
y_n_input(prompt, error_msg="Enter y or n.", bool_return=False)
Asks a simple Yes or No question. Handles white spaces and capitalizations effortlessly.
* Arguments:
* prompt (str): The question text.
* error_msg (str): What to print if they do not type a valid "y" or "n".
* bool_return (bool): If True, returns a Python boolean (True/False). If False, returns the string "y" or "n".
* Returns: bool or str
Fuzzy Matching Utilities (fuzzy)
Tools used to handle string matching and typos using fuzzy text ratios. Note: This module requires the external library thefuzz.
similarity_check(item, check, no_similarity_msg="...", similarity_needed=85)
Compares a single target string against a list of possibilities and returns the closest match if it passes a threshold score.
* Arguments:
* item (str): The string you want to look up.
* check (list): A list of strings to search through.
* similarity_needed (int): The required matching percentage score (0-100). Default is 85.
* Returns: str (The closest matching item from your list, or "error" if no matches are close enough).
similarity_compare(item1, item2, similarity_needed=85, no_similarity_msg="...")
Directly compares two individual strings to see if they are close enough to be considered a match.
* Returns: str (Returns item2 if they match, or "error" if they don't).
File Operations (file_edits)
Quick wrappers to open, read, write, or update local text files without writing boilerplate context managers.
read_file(filename, chars=None, lines=None, include_newline=True)
Flexible file reader that can pull an entire file, grab specific characters, or look at a specific number of lines.
* Arguments:
* filename (str): The path to the file.
* chars (int): Number of characters to read from the top.
* lines (int): Number of total lines to pull from the top.
* include_newline (bool): Set to False to automatically strip trailing newlines from your output lines.
* Returns: str
write_file(filename, content)
Creates a new file (or overwrites an existing one) and writes text content directly to it.
append_to_file(filename, content)
Opens a file and cleanly appends new content to the very end of it without removing existing text.