User Input/Output¶
Utility Functions¶
- mil_tools.get_ch()[source]¶
Gets a single character from stdin. Doesn’t echo to screen. Catches
CTRL-C
andCTRL-E
and raises exceptions.- Raises
KeyboardInterrupt – The user presses
CTRL-C
EOFError – The user presses
CTRL-D
character (theEOF
characetr)
FPrintFactory¶
- deffprint
- class mil_tools.FprintFactory(title: Optional[str] = None, time: Optional[Callable] = None, msg_color: Optional[str] = None, auto_bold: bool = True, newline: int = 1)[source]¶
Factory method for producing a printer with the specified characteristics.
- Parameters
title (Optional[str]) – The title to produce with each printed message.
time (Optional[Callable]) – A method for getting the time to produce with each method. If
None
, then no time is sent with a message.msg_color (Optional[str]) – The color of each message. If
None
, defaults to white.auto_bold (bool) – Automatically bolds each method. Defaults to
True
.newline (int) – The number of newlines to print after each method.
- fprint(text: str, **kwargs)[source]¶
Prints some text with the specified characteristics. Characteristics can be passed through the kwargs argument or through the class’ constructor.
- Parameters
text (str) – The text to format and then print
kwargs – Any characteristics to print with the text. All keyword arguments are the same as the arguments specified in the constructor.
File Input/Output¶
Utility Functions¶
- mil_tools.download(url: str, output_filename: Optional[str] = None) str [source]¶
Downloads the contents of a particular URL. If an output filename is also specified, the filename is written to with the URL contents.