lib.io module
Helper utilities related to IO.
- class colors[source]
Bases:
objectNamespace for <color>() functions.
- black()
- Parameters
msg (
str) –- Return type
str
- blue()
- Parameters
msg (
str) –- Return type
str
- cyan()
- Parameters
msg (
str) –- Return type
str
- green()
- Parameters
msg (
str) –- Return type
str
- magenta()
- Parameters
msg (
str) –- Return type
str
- red()
- Parameters
msg (
str) –- Return type
str
- white()
- Parameters
msg (
str) –- Return type
str
- yellow()
- Parameters
msg (
str) –- Return type
str
- confirm(prompt)[source]
Prompt user for ‘y’ or ‘n’ answer.
- Return type
bool- Returns
True iff the user responds to the @prompt with ‘y’.
- Parameters
prompt (
str) –
- copy_to_clipboard(clip)[source]
Copys a clip to the system clipboard.
- Parameters
clip (
str) – The clip that gets copied into the clipboard.- Return type
None
- create_dir(directory)[source]
Create directory if it does not already exist.
- Parameters
directory (
str) – The full directory path.- Return type
None
- efill(multiline_msg, width=80, indent=0)[source]
A better version of textwrap.fill().
- Parameters
multiline_msg (
str) –width (
int) –indent (
int) –
- Return type
str
- ewrap(multiline_msg, width=80, indent=0)[source]
A better version of textwrap.wrap().
- Parameters
multiline_msg (
str) –width (
int) –indent (
int) –
- Return type
Iterator[str]
- getch(prompt=None)[source]
Reads a single character from stdin.
- Parameters
prompt (
Optional[str]) – prompt that is presented to user.- Return type
str- Returns
The single character that was read.
- mkfifo(fifo_path)[source]
Creates named pipe if it does not already exist.
- Parameters
fifo_path (
str) – The full file path where the named pipe will be created.- Return type
None
- notify(*args, title=None, urgency=None, up=0)[source]
Sends desktop notification with calling script’s name as the notification title.
- Parameters
*args – Arguments to be passed to the notify-send command.
title (
Optional[str]) – Notification title.urgency (
Optional[str]) – Notification urgency.up (
int) – How far should we crawl up the stack to get the script’s name?args (
str) –
- Return type
None