| |
@@ -26,6 +26,7 @@
|
| |
import readline
|
| |
import sys
|
| |
import termios
|
| |
+ from textwrap import wrap
|
| |
|
| |
# third-party python modules
|
| |
from bodhi.client.bindings import BodhiClient, BodhiClientException
|
| |
@@ -33,8 +34,6 @@
|
| |
import dnf
|
| |
import munch
|
| |
import requests
|
| |
- from textwrap import wrap
|
| |
-
|
| |
|
| |
PROMPT = "Comment? -1/0/1 -> karma, 'i' -> ignore, other -> skip> "
|
| |
|
| |
@@ -138,7 +137,7 @@
|
| |
|
| |
if update["notes"]:
|
| |
values["notes"] = "%s\n" % FEK_helper.wrap_paragraphs_prefix(
|
| |
- update["notes"].split("\r\n"), first_prefix=" Notes: ",
|
| |
+ update["notes"].splitlines(), first_prefix=" Notes: ",
|
| |
width=width
|
| |
)
|
| |
else:
|
| |
@@ -158,6 +157,14 @@
|
| |
|
| |
text = comment['text']
|
| |
|
| |
+ # When text is left as one chunk even if it is multiline,
|
| |
+ # the wrap function used later on eats all the whitespaces
|
| |
+ # and removes the linebreaks.
|
| |
+ # If prevented using the replace_whitespace=False built-in
|
| |
+ # settings, one cannot control the indentation any more.
|
| |
+ # For this reason, let us split the comment on new lines.
|
| |
+ text = text.splitlines()
|
| |
+
|
| |
# the format of the user has changed, add a data member
|
| |
comment["username"] = comment["user"]["name"]
|
| |
|
| |
@@ -200,11 +207,20 @@
|
| |
# when they are not from the Bodhi user.
|
| |
tint = "reset"
|
| |
|
| |
+
|
| |
+ # If there is text (if bodhi-comments is none or important
|
| |
+ # the text might be empty. In that case we'd skip it.
|
| |
if text:
|
| |
- wrapped = wrap(color(text.strip(), tint, colorize),
|
| |
+ # Deal with each line of the comment separately to
|
| |
+ # enable correct indentation.
|
| |
+ for line in text:
|
| |
+ # Skip empty lines to keep the output more compact.
|
| |
+ if not line:
|
| |
+ continue
|
| |
+ wrapped = wrap(color(line.strip(), tint, colorize),
|
| |
initial_indent=(indent+" "),
|
| |
subsequent_indent=indent+" ", width=width)
|
| |
- comments.append("\n".join(wrapped))
|
| |
+ comments.append("\n".join(wrapped))
|
| |
|
| |
val += "\n".join(comments).lstrip() + "\n"
|
| |
values["comments"] = val
|
| |
@@ -282,13 +298,15 @@
|
| |
@staticmethod
|
| |
def return_important_comment(comment_text):
|
| |
"""Takes a Bodhi comment and returns it, if it is important,
|
| |
- or returns empty string."""
|
| |
+ or returns an empty string."""
|
| |
important = ["edited this update"]
|
| |
- # Check lines in important, whether they can be found
|
| |
- # in the comment.
|
| |
+ # Iterate over the important and test against the comment_text.
|
| |
for message in important:
|
| |
- if message in comment_text:
|
| |
- return comment_text
|
| |
+ # Comment_text might have multiple lines, so iterate over
|
| |
+ # each of them and test if we have a match.
|
| |
+ for line in comment_text:
|
| |
+ if message in line:
|
| |
+ return comment_text
|
| |
return ""
|
| |
|
| |
USAGE = """
|
| |
Earlier, Fedora Easy Karma would lose comments' line breaks
and it would put comments on one line which was not very
good with multiline comments.
This PR fixes the situation and retains multiline comments.
Fixes: https://pagure.io/fedora-easy-karma/issue/49