Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH 1/2] Split output for repoman checks into file and message
Date: Wed, 19 Feb 2014 18:37:46
Message-Id: 20140219103315.0184dd13@big_daddy.dol-sen.ca
In Reply to: [gentoo-portage-dev] [PATCH 1/2] Split output for repoman checks into file and message by Chris Reffett
1 On Wed, 19 Feb 2014 13:10:04 -0500
2 Chris Reffett <creffett@g.o> wrote:
3
4 > This wraps the output of emerge checks so that a list of length 1-2 is
5 > generated. The first element is the file, the second element (optional)
6 > is a more descriptive error message. This change will help us eventually
7 > introduce more machine-readable output formats.
8 > ---
9 > bin/repoman | 232 +++++++++++++++++++++++------------------------
10 > pym/repoman/utilities.py | 18 +++-
11 > 2 files changed, 128 insertions(+), 122 deletions(-)
12 >
13 > diff --git a/bin/repoman b/bin/repoman
14 > index 888892b..3d5dde4 100755
15 > --- a/bin/repoman
16 > +++ b/bin/repoman
17 > @@ -1402,7 +1402,7 @@ for x in effective_scanlist:
18 > repoman_settings['PORTAGE_QUIET'] = '1'
19 > if not portage.digestcheck([], repoman_settings, strict=1):
20 > stats["manifest.bad"] += 1
21 > - fails["manifest.bad"].append(os.path.join(x, 'Manifest'))
22 > + fails["manifest.bad"].append([os.path.join(x, 'Manifest')])
23 > repoman_settings.pop('PORTAGE_QUIET', None)
24 >
25
26 This looks so,so to me. I think you are much better off using a
27 namedtuple class for these errors instead. They have built-in
28 formatted printing, etc.
29
30 from collections import namedtuple
31
32 and you can have pre-defined named tuple classes that have the error
33 message already embedded.
34
35 for some examples see the pyGPG ones I created for gpg data mining:
36
37 https://github.com/dol-sen/pyGPG/blob/master/pyGPG/legend.py
38
39 NOTE: CLASSES is a list of tuples that have the info to define the
40 classes that subclass the namedtuple class. They are initialized by
41 the code at the bottom of the page when the page is first loaded into
42 memory. This format saves writing out each individual class by hand
43 and makes changes easy. It also reduced the size of the file to about
44 1/3. I have done similar to tis in 3 modules in the catalys rewrite
45 as well.
46
47 The data is then available in many ways and will have a consistent
48 output.
49 --
50 Brian Dolbec <dolsen>

Replies