CIP-dev Archive on lore.kernel.org
 help / color / Atom feed
From: "Chen-Yu Tsai (Moxa)" <wens@csie.org>
To: cip-dev@lists.cip-project.org
Cc: "SZ Lin (林上智)" <sz.lin@moxa.com>,
	"Ben Hutchings" <ben.hutchings@codethink.co.uk>
Subject: Re: [cip-dev] [cip-kernel-sec 1/3] report_affected: word-wrap for the 'description'
Date: Thu, 8 Oct 2020 15:58:32 +0800
Message-ID: <CAGb2v66FnJK0YLUxdJZFd1NdA1f+sZXsgwku+JQt3atd35WkFA@mail.gmail.com> (raw)
In-Reply-To: <20200925035927.1958987-2-daniel.sangorrin@toshiba.co.jp>


[-- Attachment #1: Type: text/plain, Size: 2362 bytes --]

On Fri, Sep 25, 2020 at 12:00 PM Daniel Sangorrin
<daniel.sangorrin@toshiba.co.jp> wrote:
>
> From: Nguyen Van Hieu <hieu2.nguyenvan@toshiba.co.jp>
>
> Currently some descriptions are quite long, and it is hard to read.
> Add line-breaks so every line is at most 80 characters long.
>
> Signed-off-by: Nguyen Van Hieu <hieu2.nguyenvan@toshiba.co.jp>
> Signed-off-by: Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
> ---
>  scripts/report_affected.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/report_affected.py b/scripts/report_affected.py
> index a97b700..a181d97 100755
> --- a/scripts/report_affected.py
> +++ b/scripts/report_affected.py
> @@ -19,6 +19,7 @@ import kernel_sec.branch
>  import kernel_sec.issue
>  import kernel_sec.version
>
> +import textwrap
>
>  def main(git_repo, remotes, only_fixed_upstream,
>           include_ignored, show_description, *branch_names):
> @@ -136,8 +137,11 @@ def main(git_repo, remotes, only_fixed_upstream,
>          if show_description:
>              print('%s:' % branch['full_name'])
>              for cve_id in sorted_cve_ids:
> -                print(cve_id, '=>',
> -                      kernel_sec.issue.load(cve_id).get('description', 'None'))
> +                description=kernel_sec.issue.load(cve_id).get('description', 'None')
> +                wrap_description = ''
> +                for line in textwrap.wrap(description, 80, break_long_words=False):
> +                    wrap_description += line + '\n  '

I believe it would be better to include the "CVE => " string in the full text
passed to textwrap. That would make all lines properly wrapped at the given
width.

Also, textwrap can handle indentation for subsequent lines, so you don't have
to handle that yourself. And it might be easier to read if they matched up
with the beginning of the description in the first line.

Last, you could use join() to combine the lines.

So I would rewrite the part as:

    text = cve_id + ' => ' +
kernel_sec.issue.load(cve_id).get('description', 'None')
    print('\n'.join(textwrap.wrap(text, 80, subsequent_indent=' ' *
(len(cve_id) + 4), break_long_words=False)))


ChenYu
Moxa


> +                print(cve_id, '=>',wrap_description)
>          else:
>              print('%s:' % branch['full_name'], *sorted_cve_ids)
>
> --
> 2.25.1
>
>
> 
>

[-- Attachment #2: Type: text/plain, Size: 420 bytes --]


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#5509): https://lists.cip-project.org/g/cip-dev/message/5509
Mute This Topic: https://lists.cip-project.org/mt/77073066/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-


  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25  3:59 [cip-dev] improve show-description results Daniel Sangorrin
2020-09-25  3:59 ` [cip-dev] [cip-kernel-sec 1/3] report_affected: word-wrap for the 'description' Daniel Sangorrin
2020-10-08  7:58   ` Chen-Yu Tsai (Moxa) [this message]
2020-09-25  3:59 ` [cip-dev] [cip-kernel-sec 2/3] report_affected: Delete extra blank lines between CVEs Daniel Sangorrin
2020-10-08  7:59   ` Chen-Yu Tsai (Moxa)
2020-10-08  8:00     ` Chen-Yu Tsai (Moxa)
2020-09-25  3:59 ` [cip-dev] [cip-kernel-sec 3/3] issues: fill in the description field of remaining CVEs Daniel Sangorrin
2020-10-08  8:18   ` Chen-Yu Tsai (Moxa)
2020-10-14  4:16     ` Daniel Sangorrin
2020-10-14  4:21       ` Chen-Yu Tsai (Moxa)
2020-09-30  3:29 ` [cip-dev] improve show-description results Chen-Yu Tsai (Moxa)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGb2v66FnJK0YLUxdJZFd1NdA1f+sZXsgwku+JQt3atd35WkFA@mail.gmail.com \
    --to=wens@csie.org \
    --cc=ben.hutchings@codethink.co.uk \
    --cc=cip-dev@lists.cip-project.org \
    --cc=sz.lin@moxa.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

CIP-dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cip-dev/0 cip-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cip-dev cip-dev/ https://lore.kernel.org/cip-dev \
		cip-dev@lists.cip-project.org
	public-inbox-index cip-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.cip-project.lists.cip-dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git