plugins.diff: fixes diff plugin to get multiple variants

Since we have one variant per suite now, this plugin needs to get the
list of variants instead of only one.
Signed-off-by: NBeraldo Leal <bleal@redhat.com>
上级 a5f938bb
...@@ -333,14 +333,20 @@ class Varianter: ...@@ -333,14 +333,20 @@ class Varianter:
@classmethod @classmethod
def from_resultsdir(cls, resultsdir): def from_resultsdir(cls, resultsdir):
""" """
Retrieves the job variants object from the results directory. Retrieves the job variants objects from the results directory.
This will return a list of variants since a Job can have multiple
suites and the variants is per suite.
""" """
path = os.path.join(resultsdir, 'jobdata', VARIANTS_FILENAME) path = os.path.join(resultsdir, 'jobdata', VARIANTS_FILENAME)
if not os.path.exists(path): if not os.path.exists(path):
return None return None
variants = []
with open(path, 'r') as variants_file: with open(path, 'r') as variants_file:
return cls(state=json.load(variants_file)) for variant in json.load(variants_file):
variants.append(cls(state=variant))
return variants
def __len__(self): def __len__(self):
return self._no_variants return self._no_variants
...@@ -390,7 +390,8 @@ class Diff(CLICmd): ...@@ -390,7 +390,8 @@ class Diff(CLICmd):
results = [] results = []
variants = Varianter.from_resultsdir(resultsdir) variants = Varianter.from_resultsdir(resultsdir)
if variants is not None: if variants is not None:
results.extend(variants.to_str(variants=2).splitlines()) for variant in variants:
results.extend(variant.to_str(variants=2).splitlines())
else: else:
results.append('Not found\n') results.append('Not found\n')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册