abc-classroom.utils

exception abcclassroom.utils.Error[source]

Bases: OSError

abcclassroom.utils.chdir(path)[source]

Change working directory to path and restore old path on exit. path can be None in which case this is a no-op.

abcclassroom.utils.flush_inline_matplotlib_plots()[source]

Flush matplotlib plots immediately, rather than asynchronously. Basically, the inline backend only shows the plot after the entire cell executes, which means we can’t easily use a contextmanager to suppress displaying it. See https://github.com/jupyter-widgets/ipywidgets/issues/1181/ and https://github.com/ipython/ipython/issues/10376 for more details. This function displays flushes any pending matplotlib plots if we are using the inline backend.

Stolen from https://github.com/jupyter-widgets/ipywidgets/blob/4cc15e66d5e9e69dac8fc20d1eb1d7db825d7aa2/ipywidgets/widgets/interaction.py#L35 # noqa: E501

abcclassroom.utils.get_abspath(testpath, coursepath)[source]

Create an absoluate path of testpath inside coursepath if testpath is not already absolute.

abcclassroom.utils.get_editor()[source]
abcclassroom.utils.get_request(url, token=None)[source]
abcclassroom.utils.hide_outputs()[source]

Context manager for hiding outputs from display() calls.

IPython handles matplotlib outputs specially, so those are supressed too.

abcclassroom.utils.input_editor(default_message=None)[source]

Ask for user input via a text editor

abcclassroom.utils.write_file(filepath, contents)[source]

Write a new file with the given path. Each item in contents is a line in the file.