Skip to content

Commit

Permalink
Add new configuration options for custom separator
Browse files Browse the repository at this point in the history
  • Loading branch information
mweetman-redhat authored and psss committed Jan 30, 2023
1 parent 50a0128 commit ae92aba
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
16 changes: 16 additions & 0 deletions did/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ def width(self):
except (NoOptionError, NoSectionError):
return MAX_WIDTH

@property
def separator(self):
""" Separator character to use for the report """
try:
return self.parser.get("general", "separator")
except (NoOptionError, NoSectionError):
return "~"

@property
def separator_width(self):
""" Number of separator characters to use for the report """
try:
return int(self.parser.get("general", "separator_width"))
except (NoOptionError, NoSectionError):
return 79

def sections(self, kind=None):
""" Return all sections (optionally of given kind only) """
result = []
Expand Down
6 changes: 3 additions & 3 deletions did/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ def main(arguments=None):
print(header)
team_stats = UserStats(options=options)
if options.merge:
utils.header("Total Report")
utils.header("Total Report", did.base.Config().separator_width, did.base.Config().separator)
utils.item("Users: {0}".format(len(users)), options=options)

# Check individual user stats
for user in users:
if options.merge:
utils.item(user, 1, options=options)
else:
utils.header(user)
utils.header(user, did.base.Config().separator_width, did.base.Config().separator)
user_stats = UserStats(user=user, options=options)
user_stats.check()
team_stats.merge(user_stats)
Expand All @@ -227,7 +227,7 @@ def main(arguments=None):
# Display merged team report
if options.merge or options.total:
if options.total:
utils.header("Total Report")
utils.header("Total Report", did.base.Config().separator_width, did.base.Config().separator)
team_stats.show()

# Return all gathered stats objects
Expand Down
4 changes: 2 additions & 2 deletions did/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ def load_components(*paths, **kwargs):
return num_loaded


def header(text):
def header(text, separator_width=79, separator="~"):
""" Show text as a header. """
print("\n{0}\n {1}\n{0}".format(79 * "~", text))
print("\n{0}\n {1}\n{0}".format(separator_width * separator, text))


def shorted(text, width=79):
Expand Down
6 changes: 5 additions & 1 deletion docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ General
Minimum config file should contain at least a ``general`` section
with an email address which will be used for searching. Option
``width`` specifies the maximum width of the report, ``quarter``
can be used to choose a different start month of the quarter::
can be used to choose a different start month of the quarter.
The ``separator`` and ``separator_width`` options control the
character used, and width of the separator between users::

[general]
email = Petr Šplíchal <[email protected]>
width = 79
quarter = 1
separator = #
separator_width = 20

In order to load additional plugins from your custom locations
provide paths to be searched in the ``plugins`` option::
Expand Down

0 comments on commit ae92aba

Please sign in to comment.