Small modules¶
argparser_to_readme¶
- jflib.argparser_to_readme.argparser_to_readme(argparser, template='README-template.md', destination='README.md', indentation=0, placeholder='{{ argparse }}')[source]¶
Add the formatted help output of a command line utility using the Python module argparse to a README file.
- Parameters
argparser (object) – The argparse parser object.
template (str) – The path of a template text file containing the placeholder. Default: README-template.md
destination (str) – The path of the destination file. Default: README.me
indentation (int) – Indent the formatted help output by X spaces. Default: 0
placeholder (str) – Placeholder string that gets replaced by the formatted help output. Default: {{ argparse }}
- Return type
capturing¶
Capture the stdout or stderr output.
Capture stdout:
with Capturing() as output:
print('line 1')
is equivalent to
with Capturing(stream='stdout') as output:
print('line 1')
Capture stderr:
with Capturing(stream='stderr') as output:
print('line 1', file=sys.stderr)
send_email¶
- jflib.send_email.send_email(from_addr, to_addr, subject, body, smtp_login, smtp_password, smtp_server)[source]¶
Send a email.
- Parameters
from_addr (
str
) – The email address of the sender.to_addr (
str
) – The email address of the recipient.subject (
str
) – The email subject.body (
str
) – The email body.smtp_login (
str
) – The SMTP login name.smtp_password (
str
) – The SMTP password.smtp_server (
str
) – The URL of the SMTP server, for example: smtp.example.com:587.
- Returns
Problems
termcolor¶
ANSII Color formatting for output in terminal.
- jflib.termcolor.colored(text, color=None, on_color=None, attrs=None)[source]¶
Colorize text.
- Available text colors:
red, green, yellow, blue, magenta, cyan, white.
- Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
- Available attributes:
bold, dark, underline, blink, reverse, concealed.
- Example:
colored(‘Hello, World!’, ‘red’, ‘on_grey’, [‘blue’, ‘blink’]) colored(‘Hello, World!’, ‘green’)
- Return type
- jflib.termcolor.remove_color(text)[source]¶
https://stackoverflow.com/a/14693789/10193818
- Return type
utils¶
Small utility functions.