def clean(target): for item in shelltools.listdir(target): path = os.path.join(target, item) if os.path.isdir(path): shelltools.remove_dir(path) else: shelltools.remove_file(path)
def clean_temporary_directory(self): '''Cleans temporary directory which contains source code and building environment.''' def clean(target): for item in shelltools.listdir(target): path = os.path.join(target, item) if os.path.isdir(path): shelltools.remove_dir(path) else: shelltools.remove_file(path) # dont remove these directories which are located in work_dir exceptions = ('install', 'source') if shelltools.listdir(self.internals.env.build_dir): clean(self.internals.env.build_dir) if shelltools.listdir(self.internals.env.install_dir): clean(self.internals.env.install_dir) # Now, clean workdir for item in shelltools.listdir(self.internals.env.work_dir): if not item in exceptions: path = os.path.join(self.internals.env.work_dir, item) if os.path.isdir(path): shelltools.remove_dir(path) else: shelltools.remove_file(path)
def ls(target): return shelltools.listdir(target)