Gentoo Archives: gentoo-portage-dev

From: Chris Reffett <creffett@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH v2] Add --output-style option to repoman
Date: Fri, 14 Feb 2014 18:20:19
Message-Id: 52FE5E53.50604@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH v2] Add --output-style option to repoman by Brian Dolbec
1 On 2/13/2014 10:42 AM, Brian Dolbec wrote:
2 > On Thu, 13 Feb 2014 03:19:35 -0500
3 > Mike Frysinger <vapier@g.o> wrote:
4 >
5 >> On Monday, February 10, 2014 20:22:36 Chris Reffett wrote:
6 >>> This patch adds a --output-style option to repoman, which gives the
7 >>> user a choice of output formats for the repoman checks. Choices are
8 >>> "default" (current style) and "column" (a greppable format), but it
9 >>> should be easy to add more. Fixes bug 481584.
10 >>
11 >> i'd expect a proper structured output would make sense to include in
12 >> the default set. like JSON. just create a dict and send it to
13 >> json.dump().
14 >
15 > He is working on more changes to repoman and the output. So, if you
16 > can, Chris, then do it, add a json option.
17 >
18 Sure, I'll take a crack at this.
19 >
20 >>
21 >>> v2: Fix docstring to be complete and in the standard format, make
22 >>> use of default choices in --output-style wrt comments by antarus
23 >>> and dol-sen
24 >>
25 >> erm, i thought the previous docstring was correct. it followed
26 >> PEP257 while this new one is like javadoc or something.
27 >>
28 >
29 > It is the existing format that has been around in portage for years.
30 > There is even a page for it:
31 >
32 > http://www.gentoo.org/proj/en/portage/doc/policies/docstring-spec.xml
33 >
34 > It is also the style that epydoc recognizes.
35 >
36 >>> -utilities.format_qa_output(f, stats, fails, dofull, dofail,
37 >>> options, qawarnings)
38 >>> +if options.output_style == 'column':
39 >>> + utilities.format_qa_output_column(f, stats, fails, dofull,
40 >>> dofail, options, qawarnings)
41 >>> +else:
42 >>> + utilities.format_qa_output(f, stats, fails, dofull,
43 >>> dofail, options, qawarnings)
44 >>
45 >> use a func pointer instead.
46 >> format_outputs = {
47 >> 'column': utilities.format_qa_output_column,
48 >> 'default': utilities.format_qa_output,
49 >> }
50 >> format_output = format_outputs.get(options.output_style,
51 >> format_outputs['default'])
52 >> format_output(f, stats, fails, dofull, dofail, options, qawarnings)
53 >>
54 >
55 > yeah, make it so. Good spot, Mike
56 >
57 Will make this change when I'm back at my devbox (probably Mondayish).
58 >
59 > Since Mike was too slow in replying, make another commit to change
60 > it.
61 >
62 >>> + formatter.add_literal_data("NumberOf " + category
63 >>> + " ")
64 >>
65 >> prefer to use % rather than + like so:
66 >> 'NumberOf %s ' % category
67 >>
68 >>> + formatter.add_literal_data("%s" % number)
69 >>
70 >
71 > well actually, for simple additions like that, string1 + string2, it is
72 > actually faster.
73 > But for multiple additions, %s is much better, faster. Also if the
74 > string is translated, then use %s regardless. That way the %s can be
75 > moved around for the translation.
76 >
77 >> str(number)
78 >> -mike
79 >
80 >
81 >