ienv

ienv.stats

Stats will go here eventually

def print_stats()

Doesn’t do much yet really.

ienv.squish

This bit moves your files around.

BUFFER_SIZE

10MB chunks

hash_and_copy

def hash_and_copy(source, dest=None)

If we can’t use a hardlink to do a quick copy then we’ll have to do a full copy. This function will hash the file as it copies it, if there’s a dest.

backup_file

def backup_file(source, dest_dir)

You can bet the user will get bored and CTRL+C out and endup with missing files, which we don’t really want. This function tries to hardlink the file first, and if that fails it’ll do a full copy while hashing its contents. It’s not perfect, but it’ll make it pretty hard to lose data.

def replace_with_symlink(source, dest)

Replace the source file with a symlink to the dest file, after the backup has been made. This is atomic on Linux, but not on Windows. But either way, if you lose a file because you were interrupted while renaming one file over the top of another then you’re really unlucky, as well as having a crap OS.

process_venv

def process_venv(venv_dir)

Actually iterate over all the files.

Make backups into the cache dir, make a link to the backup, copy its attribs and then move the link over the source.

ienv.main

Entrypoint to the module.

ienv.venv

Deals with virtual environments.

MIN_FILE_SIZE

4k, size of a single block on most filesystems

venv_dir

def venv_dir(directory)

Validates a “venv_dir” and acts as a custom type. Not really needed but I like this sort of thing.

get_package_files

def get_package_files(venv_dir)

Return all the files under site-packages in the given venv.

get_large_package_files

def get_large_package_files(venv_dir)

Return all the files in a venv that are larger than MIN_FILE_SIZE.

ienv.cache

The cache dir, which lives at ~/.cache/ienv

It’s where all your files have been moved to.

get_cache_dir

def get_cache_dir(prefix="~")

Return the cache dir, creating it if it doesn’t exist.

load_venv_list

def load_venv_list(file_path)

Load the list of venvs that have been squished.

save_venv_list

def save_venv_list(file_path, venvs)

Save the list of venvs that have been squished.

ienv.__main__