abc-classroom.utils

exception abcclassroom.utils.Error[source]

Bases: OSError

abcclassroom.utils.abccopytree(src, dst, symlinks=False, ignore=None, copy_function=<function copy2>, ignore_dangling_symlinks=False, dirs_exist_ok=False)[source]

Recursively copy a directory tree and return the destination directory. dirs_exist_ok dictates whether to raise an exception in case dst or any missing parent directory already exists. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. If the file pointed by the symlink doesn’t exist, an exception will be added in the list of errors raised in an Error exception at the end of the copy process. You can set the optional ignore_dangling_symlinks flag to true if you want to silence this exception. Notice that this has no effect on platforms that don’t support os.symlink. The optional ignore argument is a callable. If given, it is called with the src parameter, which is the directory being visited by copytree(), and names which is the list of src contents, as returned by os.listdir(): callable(src, names) -> ignored_names Since copytree() is called recursively, the callable will be called once for each directory that is copied. It returns a list of names relative to the src directory that should not be copied. The optional copy_function argument is a callable that will be used to copy each file. It will be called with the source path and the destination path as arguments. By default, copy2() is used, but any function that supports the same signature (like copy()) can be used.

abcclassroom.utils.copy_files(src_dir, dest_dir, files_to_ignore=None)[source]

Copies contents of src_dir into dest_dir, creating dest_dir if it does not exist. Uses ‘files_to_ignore’ list to determine what not to copy. Copies subdirectories recursively. Overwrites existing files with the same path. Implements the python 3.8 version of copytree, which allows dest_dir to exits.

Throws FileNotFoundError if src_dir does not exist.

Parameters
  • src_dir (path) – Directory to copy files from. Must exist.

  • dest_dir (path) – Directory to copy files to. Must exist.

  • files_to_ignore (list) – List of file patterns to ignore.

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.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.