Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH v3] repoman: unroll escaped lines so we can check the entirety of it
Date: Fri, 25 May 2012 09:09:55
Message-Id: 4FBF471C.4090403@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v3] repoman: unroll escaped lines so we can check the entirety of it by Mike Frysinger
1 On 05/24/2012 10:22 PM, Mike Frysinger wrote:
2 > Sometimes people wrap long lines in their ebuilds to make it easier to
3 > read, but this causes us issues when doing line-by-line checking. So
4 > automatically unroll those lines before passing the full content down
5 > to our checkers.
6 >
7 > Signed-off-by: Mike Frysinger <vapier@g.o>
8 > ---
9 > v3
10 > - use import codecs for escaping strings
11
12 It looks good to me, except for this one part, where we should let
13 SystemExit raise:
14
15 > + try:
16 > + # A normal line will end in the two bytes: <\> <\n>. So decoding
17 > + # that will result in python thinking the <\n> is being escaped
18 > + # and eat the single <\> which makes it hard for us to detect.
19 > + # Instead, strip the newline (which we know all lines have), and
20 > + # append a <0>. Then when python escapes it, if the line ended
21 > + # in a <\>, we'll end up with a <\0> marker to key off of. This
22 > + # shouldn't be a problem with any valid ebuild ...
23 > + line_escaped = unicode_escape(line.rstrip('\n') + '0')
24
25 + except SystemExit:
26 + raise
27
28 > + except:
29
30
31 --
32 Thanks,
33 Zac

Replies