def remove_content(self): dirs = [] for _file in self.filesdb.get_paths_by_package(self.name, category=self.category, version=self.version): _file = _file[0] target = os.path.join(self.real_root, _file[1:]) if os.path.dirname(_file[1:]) == cst.info: utils.update_info_index(target, dir_path=os.path.join(self.real_root, cst.info, "dir"), delete=True) if os.path.islink(target): os.unlink(target) elif os.path.isfile(target): if os.path.exists(target): shelltools.remove_file(target) else: dirs.append(target) dirs.reverse() for target in dirs: if os.path.isdir(target) and not os.listdir(target): shelltools.remove_dir(target)
def update_info_index(self): for info_file in self.info_files: if os.path.exists(info_file): utils.update_info_index(info_file)