Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Atharva Lele <itsatharva@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 5/6] autobuild-run: initial implementation of get_reproducibility_failure_reason()
Date: Wed, 07 Aug 2019 11:37:45 +0530	[thread overview]
Message-ID: <11884660.vbZKco2bxD@msi-manjaro> (raw)
In-Reply-To: <20190806222118.79871663@windsurf.home>

On Wednesday, August 7, 2019 1:51:18 AM IST Thomas Petazzoni wrote:
> Hello Atharva,
> 
> On Tue,  6 Aug 2019 23:42:50 +0530
> 
> Atharva Lele <itsatharva@gmail.com> wrote:
> > +            if json_data["unified_diff"] == None:
> > +                if json_data["details"][0]["source1"] == "file list":
> > +                    json_data["details"].pop(0)
> > +
> > +                for i in range(0, len(json_data["details"])):
> > +                    diff_source = json_data["details"][i]["source1"]
> > +                    with open(packages_file_list, "r") as packagef:
> > +                        for line in packagef:
> > +                            if diff_source in line:
> > +                                package = line.split(',')[0]
> > +
> > +                    # Get package version
> > +                    package_info =
> > json.loads(subprocess.check_output(["make", "--no-print-directory", +    
> >                                                                   "O=%s"
> > % self.outputdir, +                                                      
> >                 "-C", self.srcdir, +                                     
> >                                  "%s-show-info" % package])) +           
> >         if "version" in package_info[package]:
> > +                        version = package_info[package]["version"]
> > +                        reason = [package, version]
> > +                    else:
> > +                        reason = [package]
> > +                    json_data["details"][i]["package"] = reason
> > +                    json_data["details"][i].pop("source2")
> > +                    if json_data["details"][i]["unified_diff"] == None:
> > +                        json_data["details"][i].pop("unified_diff")
> > +                        for j in range(0,
> > len(json_data["details"][i]["details"])): +                           
> > delta = json_data["details"][i]["details"][j]["unified_diff"].split("\n")
> > +                            deltas = clean_delta(delta)
> > +                           
> > json_data["details"][i]["details"][j]["added"] = deltas[0][:100] +       
> >                     json_data["details"][i]["details"][j]["deleted"] =
> > deltas[1][:100] +                            try:
> > +                               
> > json_data["details"][i]["details"][j].pop("unified_diff") +              
> >                  json_data["details"][i]["details"][j].pop("source2") +  
> >                          except KeyError as e:
> > +                                log_write(self.log, "KeyError: %s not
> > found in JSON details[%d][%d]" % (e, i, j)) +                    else:
> > +                        delta = json_data["details"][i]["unified_diff"]
> > +                        deltas = clean_delta(delta)
> > +                        json_data["details"][i]["added"] =
> > deltas[0][:100]
> > +                        json_data["details"][i]["deleted"] =
> > deltas[1][:100] +                        try:
> > +                            json_data["details"][i].pop("unified_diff")
> > +                            json_data["details"][i].pop("source2")
> > +                        except KeyError as e:
> > +                            log_write(self.log, "KeyError: %s not found
> > in JSON details[%d]" % (e, i)) +                reason =
> > json_data["details"][0]["package"]
> 
> Wow. This is way too complicated, and needs to be split into
> sub-functions, and local variables should be used to make this clearer.
> Perhaps a few comments in the code would also help.
>

Noted.
 
> Also, I believe doing loops with range(0, len(a list)) is not very
> pythonic, a more pythonic way is:
> 
> 	for item in a_list:
> 		... do something with item ...
> 

Noted.

> But clearly, having sub-functions each doing one part of the job would
> help a lot.
> 
> Thanks,
> 
> Thomas

I'll refactor it with sub-functions and the other suggestions and resend the 
patches.

Thanks for the review!

Regards,
Atharva Lele

  reply	other threads:[~2019-08-07  6:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06 18:12 [Buildroot] [PATCH 1/6] autobuild-run: use different output directories for reproducible builds testing Atharva Lele
2019-08-06 18:12 ` [Buildroot] [PATCH 2/6] autobuild-run: make prepare_build() clean the output directory used for reproducibility testing Atharva Lele
2019-08-06 18:12 ` [Buildroot] [PATCH 3/6] autobuild-run: fix cross tools prefix for diffoscope Atharva Lele
2019-08-06 20:18   ` Thomas Petazzoni
2019-08-06 18:12 ` [Buildroot] [PATCH 4/6] autobuild-run: make diffoscope output to a JSON-formatted file Atharva Lele
2019-08-06 19:40   ` Thomas Petazzoni
2019-08-07  6:12     ` Atharva Lele
2019-08-06 18:12 ` [Buildroot] [PATCH 5/6] autobuild-run: initial implementation of get_reproducibility_failure_reason() Atharva Lele
2019-08-06 20:21   ` Thomas Petazzoni
2019-08-07  6:07     ` Atharva Lele [this message]
2019-08-06 18:12 ` [Buildroot] [PATCH 6/6] autobuild-run: account for reproducibility failures in get_failure_reason() Atharva Lele
2019-08-06 19:37 ` [Buildroot] [PATCH 1/6] autobuild-run: use different output directories for reproducible builds testing Thomas Petazzoni
2019-08-07  6:02   ` Atharva Lele
2019-08-07  8:33     ` Thomas Petazzoni

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=11884660.vbZKco2bxD@msi-manjaro \
    --to=itsatharva@gmail.com \
    --cc=buildroot@busybox.net \
    /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