Skip to content

Commit

Permalink
pkglistgen: tool: decouple summary dict creation
Browse files Browse the repository at this point in the history
The summary dictionary used to create summary-{scope}.txt was
previously returned by solve_project() via write_all_groups().

After c46dd3e, solve_project()
doesn't return anything anymore, as write_all_groups() is being
invoked just after solve_project().

Thus, the "summary" dictionary would always be None.

Since the summary dict creation is generic enough, move it
to its own function, and call it afterwards after project
solving.

This commit also drops the return statement both on write_all_groups()
and write_productcompose() (where it would always return an empty
dictionary), and moves the write_productcompose() call after
solve_project() as well to match the change with write_all_groups().

Signed-off-by: Eugenio Paolantonio <eugenio.paolantonio@suse.com>
  • Loading branch information
g7 authored and Vogtinator committed May 14, 2024
1 parent ed30d28 commit d297625
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions pkglistgen/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def write_group_stubs(self):

def write_productcompose(self):
self._check_supplements()
summary = dict()
archs = ['*'] + self.all_architectures
# a single file covering all builds via multibuild flavors
with open(os.path.join(self.productcompose_dir, 'default.productcompose'), 'a') as opfh:
Expand Down Expand Up @@ -178,17 +177,13 @@ def write_productcompose(self):
for included_arch in self.all_architectures:
opfh.write(' - ' + f + '_' + included_arch + '\n')

return summary

def write_all_groups(self):
self._check_supplements()
summary = dict()
archs = ['*'] + self.all_architectures
for name in self.groups:
group = self.groups[name]
if not group.solved:
continue
summary[name] = group.summary()
fn = f'{group.name}.group'
with open(os.path.join(self.output_dir, fn), 'w') as fh:
comment = group.comment
Expand All @@ -200,6 +195,15 @@ def write_all_groups(self):
x = re.sub(r'\s*<!-- reason:', ' <!-- reason:', x)
fh.write(x)

def make_summary(self):
self._check_supplements()
summary = dict()
for name in self.groups:
group = self.groups[name]
if not group.solved:
continue
summary[name] = group.summary()

Check warning on line 205 in pkglistgen/tool.py

View check run for this annotation

Codecov / codecov/patch

pkglistgen/tool.py#L198-L205

Added lines #L198 - L205 were not covered by tests

return summary

def solve_module(self, groupname, includes, excludes, use_recommends):
Expand Down Expand Up @@ -613,8 +617,6 @@ def solve_project(
module.solved_packages[arch].pop(p, None)

self._collect_unsorted_packages(modules, self.groups.get('unsorted'))
if not self.skip_productcompose:
self.write_productcompose()

def strip_medium_from_staging(self, path):
# staging projects don't need source and debug medium - and the glibc source
Expand Down Expand Up @@ -798,15 +800,21 @@ def update_and_solve_target(
self.load_all_groups()
self.write_group_stubs()
else:
summary = self.solve_project(
self.solve_project(

Check warning on line 803 in pkglistgen/tool.py

View check run for this annotation

Codecov / codecov/patch

pkglistgen/tool.py#L803

Added line #L803 was not covered by tests
ignore_unresolvable=str2bool(target_config.get('pkglistgen-ignore-unresolvable')),
ignore_recommended=str2bool(target_config.get('pkglistgen-ignore-recommended')),
locale=target_config.get('pkglistgen-locale'),
locales_from=target_config.get('pkglistgen-locales-from')
)

if not self.skip_productcompose:
self.write_productcompose()

Check warning on line 811 in pkglistgen/tool.py

View check run for this annotation

Codecov / codecov/patch

pkglistgen/tool.py#L810-L811

Added lines #L810 - L811 were not covered by tests

if product_dir:
self.write_all_groups()

summary = self.make_summary()

Check warning on line 816 in pkglistgen/tool.py

View check run for this annotation

Codecov / codecov/patch

pkglistgen/tool.py#L816

Added line #L816 was not covered by tests

if stop_after_solve:
return

Expand Down

0 comments on commit d297625

Please sign in to comment.