cmd[0](cmd[1]) # remove dir from cache if it's already there abspath = abspath(cmd[1]) if abspath in _path_created: del _path_created[abspath] except (IOError, OSError), exc: print exc, "error removing %s: " % directory def touch(name, mode=0777, recursive=False): if typecheck.is_list(name): name = join(*name) if not typecheck.is_string(name): raise TypeError() if not typecheck.is_int(mode): raise TypeError() if not typecheck.is_bool(recursive): raise TypeError() if recursive: mkpath(dirname(name), mode=mode) open(name, "w").close() return name def mkpath(name, mode=0777, verbose=0, dry_run=False): """Creates a file/directory and any missing ancestor directories. If the directory already exists (or if `name` is the empty string, which means the current directory, which of course exists), then do nothing. Raises :class:`OSError` if unable to create some directory along the way (eg. some sub-path exists, but is a file rather than a directory). If 'verbose' is true, print a one-line summary of each mkdir to stdout. :raises: OSError
def set_dry_run_mode(self, true_or_false): if not typecheck.is_bool(true_or_false): raise TypeError("'true_or_false' has to be boolean") self._dry_run = true_or_false