From 0568b90f7a3f041b39c12835bd81044ba8a01d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Thu, 20 Jun 2013 18:39:18 +0200 Subject: [PATCH] select_repository now handle uuid --- installsystems/repository.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/installsystems/repository.py b/installsystems/repository.py index 275693a..de0272d 100644 --- a/installsystems/repository.py +++ b/installsystems/repository.py @@ -31,6 +31,7 @@ import fnmatch import cStringIO import json import uuid +import string import installsystems import installsystems.tools as istools from installsystems.exception import * @@ -860,6 +861,22 @@ class RepositoryManager(object): ''' return [ r.config.name for r in self.repos ] + @property + def uuids(self): + ''' + Return a dict of repository UUID and associated names + ''' + d = {} + for r in self.repos: + uuid = r.uuid + if uuid is None: + continue + if uuid in d: + d[uuid].append(r) + else: + d[uuid] = [r] + return d + @property def onlines(self): ''' @@ -1030,8 +1047,12 @@ class RepositoryManager(object): Return a list of repository ''' ans = set() + uuidb = self.uuids for pattern in patterns: ans |= set(fnmatch.filter(self.names, pattern)) + if istools.strcspn(pattern, string.hexdigits + "-") == 0: + for uuid in filter(lambda x: x.startswith(pattern), uuidb.keys()): + ans |= set((r.config.name for r in uuidb[uuid])) return sorted(ans) def purge_repositories(self, patterns): -- GitLab