The cleanmymac.util Module

class cleanmymac.util.Dir(path)

Bases: tuple

a single directory

count(value) → integer -- return number of occurrences of value
index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

path

Alias for field number 0

class cleanmymac.util.DirList(dirs)

Bases: tuple

a list of directories

count(value) → integer -- return number of occurrences of value
dirs

Alias for field number 0

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

class cleanmymac.util.DiskUsage(total, used, free)

Bases: tuple

a collections.namedtuple() holding disk usage statistics

count(value) → integer -- return number of occurrences of value
free

Alias for field number 2

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

total

Alias for field number 0

used

Alias for field number 1

cleanmymac.util.delete_dir_content(folder)[source]

delete all the files and directories in path

Parameters:folder (Dir) – a valid directory path
cleanmymac.util.delete_dirs(dir_list)[source]

delete all directories in list

Parameters:dir_list (DirList) – the list of directories
cleanmymac.util.get_disk_usage(path='/', unit=1024)[source]

retrieve disk usage statistics for a given path this function was inspired by the following stackoverflow discussion: http://stackoverflow.com/questions/787776/find-free-disk-space-in-python-on-os-x

Parameters:
  • path (str) – the path (defaults to /)
  • unit (long) – the measurement unit
Returns:

the usage statistics

Return type:

DiskUsage

cleanmymac.util.progressbar(*args, **kwds)[source]

wrapper over the click.progressbar() context manager

Parameters:
  • verbose (bool) – if False use the click.progressbar(), else return iterable
  • iterable (iterable) – the iterable object
  • kwargs (dict) – extra arguments for click.progressbar()
Returns:

an iterator

Return type:

iterable

cleanmymac.util.yaml_files(path)[source]

generator of YAML files in the give path.

Parameters:path – the path to scan for YAML files
Returns:a generator
Raise:ValueError if path is not a valid directory