def search_by_PackageRef(self, ref, use_ref_repo=True, detailed=True): """ Search for PackageRef in all repos. If use_ref_repo is True, search only in repo of PackageRef if it is not None. Returns list of new PackageRefs with hash set, and new attr details if detailed is True """ if use_ref_repo and ref.repo: repos_list = [ref.repo] else: repos_list = [r.name for r in self.repos.list()] result = [] for r in repos_list: search_result = self.repos.search_packages(r, ref.dir_ref, detailed=True) logger.debug('search for "{}" in "{}": {}'.format( ref.dir_ref, r, search_result)) if len(search_result) > 1: raise AptlyCtlError( 'Search for direct reference "{}" in repo "{}" ' "returned more than 1 result.".format(ref.dir_ref, r)) elif len(search_result) == 1: new_ref = PackageRef(search_result[0].key) new_ref.repo = r new_ref.details = search_result[0] result.append(new_ref) else: return result
def test_repo_is_settable(self): r = PackageRef("main/Pamd64 aptly 2.2.0~rc5 f2b7dc2061b9d95c") assert r.repo == "main" r.repo = "extra" assert r.repo == "extra"