Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH v2] Add --output-style option to repoman
Date: Thu, 13 Feb 2014 18:04:17
Message-Id: CAAr7Pr-XGzNg=-9PanwBgG1b2tXr6sAMoCPAZU_sidgMeSDvFg@mail.gmail.com
In Reply to: Re: [gentoo-portage-dev] [PATCH v2] Add --output-style option to repoman by Brian Dolbec
1 On Thu, Feb 13, 2014 at 7:42 AM, Brian Dolbec <dolsen@g.o> wrote:
2
3 > On Thu, 13 Feb 2014 03:19:35 -0500
4 > Mike Frysinger <vapier@g.o> wrote:
5 >
6 > > On Monday, February 10, 2014 20:22:36 Chris Reffett wrote:
7 > > > This patch adds a --output-style option to repoman, which gives the
8 > > > user a choice of output formats for the repoman checks. Choices are
9 > > > "default" (current style) and "column" (a greppable format), but it
10 > > > should be easy to add more. Fixes bug 481584.
11 > >
12 > > i'd expect a proper structured output would make sense to include in
13 > > the default set. like JSON. just create a dict and send it to
14 > > json.dump().
15 >
16 > He is working on more changes to repoman and the output. So, if you
17 > can, Chris, then do it, add a json option.
18 >
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 >
58 > Since Mike was too slow in replying, make another commit to change
59 > it.
60 >
61 > > > + formatter.add_literal_data("NumberOf " + category
62 > > > + " ")
63 > >
64 > > prefer to use % rather than + like so:
65 > > 'NumberOf %s ' % category
66 > >
67 > > > + formatter.add_literal_data("%s" % number)
68 > >
69 >
70 > well actually, for simple additions like that, string1 + string2, it is
71 > actually faster.
72 > But for multiple additions, %s is much better, faster. Also if the
73 > string is translated, then use %s regardless. That way the %s can be
74 > moved around for the translation.
75 >
76
77 In general we prefer % for readability purposes, not because it is faster.
78
79 foo = "Bar" + foo + " " + baz + "," + goat
80
81 foo = "Bar %s %s, %s" % (foo, baz, goat)
82
83 I think this case could go either way, because even with %, "NumberOf%s" is
84 not much of an improvement.
85 The code is littered with the former though, and it makes it really
86 annoying to read ;)
87
88 -A
89
90
91
92 >
93 > > str(number)
94 > > -mike
95 >
96 >
97 >
98 > --
99 > Brian Dolbec <dolsen>
100 >
101 >

Replies