| |
@@ -48,7 +48,7 @@
|
| |
test_cases_url="https://fedoraproject.org/wiki/",
|
| |
wrap_bugs=True,
|
| |
width=80,
|
| |
- skip_bodhi_comments=False,
|
| |
+ bodhi_comments="important",
|
| |
colorize = True):
|
| |
|
| |
# copy update to avoid side effects
|
| |
@@ -156,10 +156,12 @@
|
| |
indent = " " * 13
|
| |
comment["indent"] = indent
|
| |
|
| |
+ text = comment['text']
|
| |
+
|
| |
# the format of the user has changed, add a data member
|
| |
comment["username"] = comment["user"]["name"]
|
| |
|
| |
- if comment['username'] == 'bodhi' and skip_bodhi_comments:
|
| |
+ if comment['username'] == 'bodhi' and bodhi_comments == "none":
|
| |
continue
|
| |
|
| |
# keep the karma value for later calculations, but do not
|
| |
@@ -178,10 +180,13 @@
|
| |
tint = "grey_50"
|
| |
# To maintain proper indentation, colorize first and then
|
| |
# deal with the indentation.
|
| |
- authoring = f"{comment['username']} - {comment['timestamp']}"
|
| |
- authoring = color(authoring, tint, colorize)
|
| |
- authoring = f"{comment['indent']}{authoring}"
|
| |
- comments.append(authoring)
|
| |
+ if bodhi_comments == "important":
|
| |
+ text = FEK_helper.return_important_comment(text)
|
| |
+ if text:
|
| |
+ authoring = f"{comment['username']} - {comment['timestamp']}"
|
| |
+ authoring = color(authoring, tint, colorize)
|
| |
+ authoring = f"{comment['indent']}{authoring}"
|
| |
+ comments.append(authoring)
|
| |
else:
|
| |
# For Non-Bodhi users, the color scheme will look a little
|
| |
# bit different: the username is bold, the karma string
|
| |
@@ -195,8 +200,8 @@
|
| |
# when they are not from the Bodhi user.
|
| |
tint = "reset"
|
| |
|
| |
- if comment["text"]:
|
| |
- wrapped = wrap(color(comment["text"].strip(), tint, colorize),
|
| |
+ if text:
|
| |
+ wrapped = wrap(color(text.strip(), tint, colorize),
|
| |
initial_indent=(indent+" "),
|
| |
subsequent_indent=indent+" ", width=width)
|
| |
comments.append("\n".join(wrapped))
|
| |
@@ -274,6 +279,18 @@
|
| |
|
| |
return ("\n%s" % subsequent_indent).join(output)
|
| |
|
| |
+ @staticmethod
|
| |
+ def return_important_comment(comment_text):
|
| |
+ """Takes a Bodhi comment and returns it, if it is important,
|
| |
+ or returns empty string."""
|
| |
+ important = ["edited this update"]
|
| |
+ # Check lines in important, whether they can be found
|
| |
+ # in the comment.
|
| |
+ for message in important:
|
| |
+ if message in comment_text:
|
| |
+ return comment_text
|
| |
+ return ""
|
| |
+
|
| |
USAGE = """
|
| |
You will be asked for every package installed from updates-testing to
|
| |
provide feedback using karma points. If patterns are provided, you will be
|
| |
@@ -341,8 +358,8 @@
|
| |
default=False)
|
| |
parser.add_argument("--datadir",
|
| |
dest="datadir",
|
| |
- help="Directory to store cache or ignore data, "
|
| |
- "default: %(default)s",
|
| |
+ help="Directory to store cache or ignore data "
|
| |
+ "(default: %(default)s)",
|
| |
default=f"{config_dir}/fedora-easy-karma")
|
| |
parser.add_argument("--debug",
|
| |
dest="debug",
|
| |
@@ -351,12 +368,12 @@
|
| |
default=False)
|
| |
parser.add_argument("--default-comment",
|
| |
dest="default_comment",
|
| |
- help="Default comment to use, default: %(default)s",
|
| |
+ help="Default comment to use (default: %(default)s)",
|
| |
default="",
|
| |
metavar="COMMENT")
|
| |
parser.add_argument("--default-karma",
|
| |
dest="default_karma",
|
| |
- help="Default karma to use, default: %(default)s",
|
| |
+ help="Default karma to use (default: %(default)s)",
|
| |
default="",
|
| |
metavar="KARMA")
|
| |
parser.add_argument("--no-color",
|
| |
@@ -385,14 +402,14 @@
|
| |
parser.add_argument("--installed-max-days",
|
| |
dest="installed_max_days",
|
| |
help="Only check packages installed within the last "
|
| |
- "XX days, default: %(default)d",
|
| |
+ "XX days (default: %(default)d)",
|
| |
metavar="DAYS",
|
| |
default=28,
|
| |
type=int)
|
| |
parser.add_argument("--installed-min-days",
|
| |
dest="installed_min_days",
|
| |
help="Only check packages installed for at least "
|
| |
- "XX days, default: %(default)d",
|
| |
+ "XX days (default: %(default)d)",
|
| |
metavar="DAYS",
|
| |
default=0,
|
| |
type=int)
|
| |
@@ -414,24 +431,24 @@
|
| |
parser.add_argument("--product",
|
| |
dest="product",
|
| |
help="product to query Bodhi for, 'F' for Fedora, "
|
| |
- "'EL-' for EPEL, default: %(default)s",
|
| |
+ "'EL-' for EPEL (default: %(default)s)",
|
| |
default="F")
|
| |
parser.add_argument("--releasever",
|
| |
dest="releasever",
|
| |
- help="releasever to query Bodhi for, "
|
| |
- "default: releasever from dnf",
|
| |
+ help="releasever to query Bodhi for "
|
| |
+ "(default: releasever from dnf)",
|
| |
default=None)
|
| |
parser.add_argument("--retries",
|
| |
dest="retries",
|
| |
help="Number if retries when submitting a comment "
|
| |
- "in case of an error, default: %(default)d",
|
| |
+ "in case of an error (default: %(default)d)",
|
| |
default=3,
|
| |
type=int)
|
| |
- parser.add_argument("--skip-bodhi-comments",
|
| |
- dest="skip_bodhi_comments",
|
| |
- help="Do not show comments created by bodhi",
|
| |
- action="store_true",
|
| |
- default=False)
|
| |
+ parser.add_argument("--bodhi-comments",
|
| |
+ dest="bodhi_comments",
|
| |
+ help="Decide which bodhi comments to show (default: %(default)s)",
|
| |
+ choices=["all", "important", "none"],
|
| |
+ default="important")
|
| |
parser.add_argument("--wrap-bugs",
|
| |
dest="wrap_bugs",
|
| |
help="Apply line-wrapping to bugs",
|
| |
@@ -444,14 +461,14 @@
|
| |
default=False)
|
| |
parser.add_argument("--wrap-width",
|
| |
dest="wrap_width",
|
| |
- help="Width to use for line wrapping of updates, "
|
| |
- "default: %(default)d",
|
| |
+ help="Width to use for line wrapping of updates "
|
| |
+ "(default: %(default)d)",
|
| |
default=80,
|
| |
type=int)
|
| |
parser.add_argument("--bodhi-request-limit",
|
| |
dest="bodhi_request_limit",
|
| |
help="Maximum number of updates to request at "
|
| |
- "once from Bodhi, default: %(default)d",
|
| |
+ "once from Bodhi (default: %(default)d)",
|
| |
default=25,
|
| |
type=int)
|
| |
parser.add_argument("--oraculum-endpoint",
|
| |
@@ -680,7 +697,7 @@
|
| |
update, bodhi_base_url=self.bc.base_url,
|
| |
width=self.options.wrap_width,
|
| |
wrap_bugs=self.options.wrap_bugs,
|
| |
- skip_bodhi_comments=self.options.skip_bodhi_comments,
|
| |
+ bodhi_comments=self.options.bodhi_comments,
|
| |
colorize=not self.options.no_color
|
| |
))
|
| |
if self.options.wrap_rpms:
|
| |
This PR introduces a change in showing bodhi comments.
Currently, the user could choose whether they want to see
bodhi comments or they want to surpress them.
Now, users can select what comments they want to see. The CLI
switch changes from
--skip-bodhi-comments
to--bodhi-comments=<var>
,where
var
can be all, important, or none. With all, all bodhicomments will be shown, with none no bodhi comments will be shown.
By default, users will be shown important bodhi comments. Currently,
important comments are these that include the edited this update
message.
Fixes: https://pagure.io/fedora-easy-karma/issue/46