diff --git a/bin/isrepo b/bin/isrepo index 98e728bee767371472d12472fcb078d5840964ac..6abbac5c489689d7b0d2f866af6713dd8dc848aa 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 d2d212ccb8a2805a4c5c6809ad5ef201c80d795c..5110f95c2e67d15fd2873696494239de6a6a3735 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)