Welcome to OSTools’s documentation!

Path

class ostools.Path(envvar='PATH')[source]

This is a class for working with PATHs, like PATH or MANPATH.

It has the interface of a list. It loads the initial list from an environment variable, and converts each element into a FilePath, with exist_required set to false.

envvar

str – The environment variable to load the paths from.

items

list – The list of paths.

append(item)[source]

This function functions like list.append(). It also converts the item into a FilePath, with exist_required set to false.

extend(items)[source]

This function functions like list.extend(). It also converts each item into a FilePath, with exist_required set to false.

insert(index, item)[source]

This function functions like list.insert(). It also converts the item into a FilePath, with exist_required set to false.

reload()[source]

Load the PATH from the environment variable specified in envvar, converting each element into a FilePath, with exist_required set to false.

FilePath

class ostools.FilePath(path='.', exist_required=True, ensure=None, lazy=False)[source]

This is a class similar to pathlib.Path.

path_list

list – The list of elements in the path. This can be modified manually.

exist_required

bool – Whether or not this path must exist. This can be modified manually.

ensure

str – Whether to create the file or directory automatically. Can be either ‘dir’, to make it a directory, or ‘file’ to make it a file. It will be created before the FilePath.exist_required check. This can be modified manually.

lazy

bool – Whether or not to run FilePath.ensure and FilePath.exist_required checks when accessing or modifying FilePath.path(). This can be modified manually.

OSTools Tutorial

Todo

Write tutorial!

Indices and tables