def fetch(self, fetcher, progress): if not os.path.isdir(self._path): raise Error, _("Channel '%s' has invalid directory: %s") % \ (self, self._path) digest = os.path.getmtime(self._path) if digest == self._digest: return True self.removeLoaders() loader = RPMDirLoader(self._path) loader.setChannel(self) self._loaders.append(loader) self._digest = digest return True
def test_RPMHeaderListLoader_searcher(self): """ Ensure getPathList is working correctly with indexes. """ # Just assert it's called at all. get_header_filenames_mock = self.mocker.replace(get_header_filenames) get_header_filenames_mock(ANY) self.mocker.passthrough() self.mocker.replay() searcher = Searcher() searcher.addPath("/tmp/file1") cache = Cache() loader = RPMDirLoader(TESTDATADIR + "/rpm", "name1-version1-release1.noarch.rpm") loader.setCache(cache) loader.load() loader.search(searcher) results = searcher.getResults() self.assertEquals(len(results), 1) self.assertEquals(results[0][0], 1.0) self.assertEquals(results[0][1].name, "name1")
def fetch(self, fetcher, progress): if not os.path.isdir(self._path): raise Error, _("Channel '%s' has invalid directory: %s") % \ (self, self._path) digest = os.path.getmtime(self._path) if digest == self._digest: return True self.removeLoaders() loader = RPMDirLoader(self._path) loader.setChannel(self) self._loaders.append(loader) if getattr(self, "_recursive", False): for root, dirs, files in os.walk(self._path): for name in dirs: loader = RPMDirLoader(os.path.join(root, name)) loader.setChannel(self) self._loaders.append(loader) self._digest = digest return True
def test_RPMDirLoader_loadFileProvides(self): returned_filenames = [] def result_callback(filenames): returned_filenames.extend(filenames) get_header_filenames_mock = self.mocker.replace(get_header_filenames) get_header_filenames_mock(ANY) self.mocker.passthrough(result_callback) self.mocker.replay() cache = Cache() loader = RPMDirLoader(TESTDATADIR + "/rpm", "name1-version1-release1.noarch.rpm") loader.setCache(cache) loader.load() loader.loadFileProvides({"/tmp/file1": "/tmp/file1"}) self.assertEquals(returned_filenames, ["/tmp/file1"])