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