From de1f38bbdd0be5f5ea4179f698020cec22b545f5 Mon Sep 17 00:00:00 2001 From: Seblu <sebastien.luttringer@smartjog.com> Date: Wed, 1 Jun 2011 13:15:32 +0200 Subject: [PATCH] selecting of repo in isrepo is smarter --- bin/isrepo | 13 ++++++++----- installsystems/config.py | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/isrepo b/bin/isrepo index 98e728b..6abbac5 100755 --- a/bin/isrepo +++ b/bin/isrepo @@ -83,12 +83,15 @@ try: args = p_main.parse_args() # load config config = ConfigFile("isrepo", args.config) - # get config repositories - repos = config.repos + # filtering on repository name if present + if args.repo_name is not None: + repos = filter(lambda x: x.name == args.repo_name, config.repos) + else: + repos = config.repos if len(repos) == 1: - args.repo = repos[repos.keys()[0]] - elif args.repo_name in repos.keys(): - args.repo = repos[args.repo_name] + args.repo = repos[0] + elif len(repos) > 1: + raise Exception("Please select a repository with -r") else: raise Exception("No image repository found") debug("Image repo: %s" % args.repo.image) diff --git a/installsystems/config.py b/installsystems/config.py index d2d212c..5110f95 100644 --- a/installsystems/config.py +++ b/installsystems/config.py @@ -49,7 +49,7 @@ class ConfigFile(object): if "image" not in cp.options(rep): continue # get all options in repo - self._repos.append( RepositoryConfig(rep, **dict(cp.items(rep)))) + self._repos.append(RepositoryConfig(rep, **dict(cp.items(rep)))) except Exception as e: raise raise Exception("Unable load file %s: %s" % (self.path, e)) @@ -89,6 +89,6 @@ class ConfigFile(object): @property def repos(self): - '''Get a dict of repository available''' + '''Get a list of repository available''' # deep copy return list(self._repos) -- GitLab