On Wed, 19 Feb 2014 13:10:04 -0500
Chris Reffett <creff...@gentoo.org> 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. 
-- 
Brian Dolbec <dolsen>


Reply via email to