Skip to content

Commit

Permalink
Couple more enhancements on conf sections
Browse files Browse the repository at this point in the history
  • Loading branch information
markgw committed Oct 26, 2020
1 parent c6c52d5 commit e6bd452
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/python/pimlico/cli/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def run_command(self, pipeline, opts):
print("\n%s:" % status)
print("\n".join(status_lists[status]))
else:
if not opts.no_sections or len(module_names) < 2:
if not pipeline.has_sections or not opts.no_sections or len(module_names) < 2:
# Show with the structure of section headings
mod_name_bullets = dict(zip(module_names, bullets))
selected_subtree = pipeline.section_headings.subtree(module_names)
Expand Down Expand Up @@ -225,7 +225,7 @@ def print_section_tree(tree, mod_name_bullets, pipeline, depth=0, expand="all"):
section_colors = [module_status_color(pipeline[mod]) for mod in tree.subtree_modules()]
# Apply consistent sorting
section_colors.sort()
print("\n{}{}".format(
print("{}{}".format(
mix_bg_colors("{} {}. {}".format("#"*depth, tree.number_str(), tree.name), section_colors),
title_suffix
))
Expand Down
7 changes: 6 additions & 1 deletion src/python/pimlico/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ def __init__(self, name, pipeline_config, local_config,
sys.path.extend(additional_paths)

if section_headings is None:
section_headings = SectionHeadings("root", self.module_order, [])
section_headings = SectionHeadings("root", [], self.module_order, [])
self.section_headings = section_headings
# Whether there is actually a structure of headings
# If it's really just a flat list, we won't try formatting headings later
self.has_sections = len(self.section_headings.subsections) > 0

# Step mode is disabled by default: see method enable_step()
self._stepper = None
Expand Down Expand Up @@ -2371,6 +2374,8 @@ def number_str(self):
return ".".join(str(n) for n in self.number)

def number_matches_subtree(self, number):
if len(number) == 0 or len(self.number) == 0:
return True
return all(x == y for (x, y) in zip(number, self.number))

def expand_module(self, old_name, new_names):
Expand Down

0 comments on commit e6bd452

Please sign in to comment.