def _remove_uninstalled_packages(self): from gentoolkit.helpers import get_installed_cpvs for cpv in self._cpvs.keys(): from gentoolkit.cpv import split_cpv scpv = rcpv = cpv.split('=')[-1].split('<')[-1].split('>')[-1] try: (category, pkg_name, version, revision) = split_cpv(rcpv) scpv = category + "/" + pkg_name except: continue if self._debug: output.debug(__file__, "scpv: %s", scpv) pred = lambda x: x.startswith(scpv) if self._debug: output.debug(__file__, "list(get_installed_cpvs(pred)): %s", list(get_installed_cpvs(pred))) output.debug(__file__, "rcpv: %s", rcpv) output.debug(__file__, "''.join(list(get_installed_cpvs(pred))): %s", ''.join(list(get_installed_cpvs(pred)))) import re if not re.search(rcpv, ''.join(list(get_installed_cpvs(pred)))): if self._verbose: output.verbose("Could not find %s installed on the system!", rcpv) self._cpvs.pop(cpv)
def Run(self): """Run the application ... We first need to read in all of our package.* files. Then we simply write them out with the correct method. We pass a flag to check for installed packages. """ files_list = [ "/etc/portage/package.use", "/etc/portage/package.unmask", "/etc/portage/package.mask", "/etc/portage/package.keywords", "/etc/portage/package.license" ] for name in files_list: if not os.access(name, os.F_OK): continue file = Package(name, self._destructive, self._sort, self._debug) file.open() if self._pretend: output.verbose("%s:", name) output.verbose(file.__unicode__()) else: file.write(self._reorganize) file.close()