From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id CBA0A138E20 for ; Wed, 19 Feb 2014 18:41:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C3051E0ADB; Wed, 19 Feb 2014 18:41:21 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 275E0E0AD1 for ; Wed, 19 Feb 2014 18:41:21 +0000 (UTC) Received: from big_daddy.dol-sen.ca (S010600222de111ff.vc.shawcable.net [96.49.5.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F29D233F923 for ; Wed, 19 Feb 2014 18:41:19 +0000 (UTC) Date: Wed, 19 Feb 2014 10:36:54 -0800 From: Brian Dolbec To: gentoo-portage-dev@lists.gentoo.org Subject: Re: [gentoo-portage-dev] [PATCH 1/2] Split output for repoman checks into file and message Message-ID: <20140219103654.6832b93b@big_daddy.dol-sen.ca> In-Reply-To: <20140219103315.0184dd13@big_daddy.dol-sen.ca> References: <1392833405-1622-1-git-send-email-creffett@gentoo.org> <1392833405-1622-2-git-send-email-creffett@gentoo.org> <20140219103315.0184dd13@big_daddy.dol-sen.ca> Organization: Gentoo X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.22; x86_64-pc-linux-gnu) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archives-Salt: ba450171-c712-46f5-abe5-eef69f88b0ac X-Archives-Hash: 853a11719bd2177ed44be6248da9d90b On Wed, 19 Feb 2014 10:33:15 -0800 Brian Dolbec wrote: > On Wed, 19 Feb 2014 13:10:04 -0500 > Chris Reffett wrote: > > > This wraps the output of emerge checks so that a list of length 1-2 is > > generated. The first element is the file, the second element (optional) > > is a more descriptive error message. This change will help us eventually > > introduce more machine-readable output formats. > > --- > > bin/repoman | 232 +++++++++++++++++++++++------------------------ > > pym/repoman/utilities.py | 18 +++- > > 2 files changed, 128 insertions(+), 122 deletions(-) > > > > diff --git a/bin/repoman b/bin/repoman > > index 888892b..3d5dde4 100755 > > --- a/bin/repoman > > +++ b/bin/repoman > > @@ -1402,7 +1402,7 @@ for x in effective_scanlist: > > repoman_settings['PORTAGE_QUIET'] = '1' > > if not portage.digestcheck([], repoman_settings, strict=1): > > stats["manifest.bad"] += 1 > > - fails["manifest.bad"].append(os.path.join(x, 'Manifest')) > > + fails["manifest.bad"].append([os.path.join(x, 'Manifest')]) > > repoman_settings.pop('PORTAGE_QUIET', None) > > > > This looks so,so to me. I think you are much better off using a > namedtuple class for these errors instead. They have built-in > formatted printing, etc. > > from collections import namedtuple > > and you can have pre-defined named tuple classes that have the error > message already embedded. > > for some examples see the pyGPG ones I created for gpg data mining: > > https://github.com/dol-sen/pyGPG/blob/master/pyGPG/legend.py > > NOTE: CLASSES is a list of tuples that have the info to define the > classes that subclass the namedtuple class. They are initialized by > the code at the bottom of the page when the page is first loaded into > memory. This format saves writing out each individual class by hand > and makes changes easy. It also reduced the size of the file to about > 1/3. I have done similar to tis in 3 modules in the catalys rewrite > as well. > > The data is then available in many ways and will have a consistent > output. for smaller simpler examples: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=blob;f=catalyst/hash_utils.py;h=cd31ad3edbdd412c0da4d968596777a71fbd4beb;hb=refs/heads/3.0 http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=blob;f=catalyst/contents.py;h=1a9ed28a58cc63ed954ca8bdbcd1b594e8a7f2e5;hb=refs/heads/3.0 -- Brian Dolbec