def empty(self): if self.exists: for root, dirs, files in walk(self.path): for d in dirs[:]: if not d.startswith(('.', '_')): Directory(abspath(root, d)).rm() dirs.remove(d) for f in files: if not f.startswith(('.', '_')): File(abspath(root, f)).rm()
def __init__(self, path): self.path = abspath(path) if self.is_root: raise FileSystemException('Root is not an acceptible directory.')
def __init__(self, path, content = None): self.path = abspath(path) self.root = Directory(op.dirname(self.path)) self.name, self.extension = op.splitext(op.basename(self.path)) self.content = content