for cmd in cmdtuples: try: 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.
def size(self, size): if not typecheck.is_int(size): raise TypeError("size must be int: %s" % size) self._size = size
def set_verbosity_level(self, level): """Set verbosity level.""" if not typecheck.is_int(level): raise TypeError() self._verbose = level