public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: Re: [PATCH] gdb: copyright: make file header scan a bit more pythonic
Date: Tue, 25 Oct 2022 09:04:39 -0400	[thread overview]
Message-ID: <Y1fe5+CK3UsO66Ns@adacore.com> (raw)
In-Reply-To: <Y1WUac0ituxgfv9Z@vapier>

Hi Mike,

On Mon, Oct 24, 2022 at 01:07:17AM +0545, Mike Frysinger via Gdb-patches wrote:
> ping ...
> -mike
> 
> On 01 Jan 2022 13:15, Mike Frysinger via Gdb-patches wrote:
> > Should be functionally the same, but uses more pythonic idioms to get
> > fewer lines of code, and to make sure to not leak open file handles.

Sorry about the delay in reviewing. The patch is approved and you can
push it.

Thanks for the patch.

> > ---
> >  gdb/copyright.py | 15 ++++++---------
> >  1 file changed, 6 insertions(+), 9 deletions(-)
> > 
> > diff --git a/gdb/copyright.py b/gdb/copyright.py
> > index a78f7f2aa9b0..918d2e473d49 100755
> > --- a/gdb/copyright.py
> > +++ b/gdb/copyright.py
> > @@ -148,15 +148,12 @@ def may_have_copyright_notice(filename):
> >      # so just open the file as a byte stream. We only need to search
> >      # for a pattern that should be the same regardless of encoding,
> >      # so that should be good enough.
> > -    fd = open(filename, "rb")
> > -
> > -    lineno = 1
> > -    for line in fd:
> > -        if b"Copyright" in line:
> > -            return True
> > -        lineno += 1
> > -        if lineno > 50:
> > -            return False
> > +    with open(filename, "rb") as fd:
> > +        for lineno, line in enumerate(fd, start=1):
> > +            if b"Copyright" in line:
> > +                return True
> > +            if lineno > 50:
> > +                break
> >      return False
> >  
> >  
> > -- 
> > 2.33.0
> > 



-- 
Joel

  reply	other threads:[~2022-10-25 13:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-01 18:15 Mike Frysinger
2022-10-23 19:22 ` Mike Frysinger
2022-10-25 13:04   ` Joel Brobecker [this message]
2022-10-25  1:16 ` Simon Marchi
2022-10-26  8:56   ` Mike Frysinger

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=Y1fe5+CK3UsO66Ns@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).