Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13551 - main/branches/2.1.6/pym/repoman
Date: Thu, 30 Apr 2009 07:30:25
Message-Id: E1LzQit-0002Gg-Rl@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-04-30 07:30:22 +0000 (Thu, 30 Apr 2009)
3 New Revision: 13551
4
5 Modified:
6 main/branches/2.1.6/pym/repoman/checks.py
7 Log:
8 Make EbuildWhitespace ignore here-documents. Thanks to Diego Petten?\195?\178
9 <flameeyes@g.o> for reporting. (trunk r13411)
10
11 Modified: main/branches/2.1.6/pym/repoman/checks.py
12 ===================================================================
13 --- main/branches/2.1.6/pym/repoman/checks.py 2009-04-30 07:30:14 UTC (rev 13550)
14 +++ main/branches/2.1.6/pym/repoman/checks.py 2009-04-30 07:30:22 UTC (rev 13551)
15 @@ -71,14 +71,29 @@
16 ignore_line = re.compile(r'(^$)|(^(\t)*#)')
17 leading_spaces = re.compile(r'^[\S\t]')
18 trailing_whitespace = re.compile(r'.*([\S]$)')
19 + here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
20
21 + def new(self, pkg):
22 + self._here_doc_delim = None
23 +
24 def check(self, num, line):
25 - if not self.leading_spaces.match(line):
26 - return errors.LEADING_SPACES_ERROR
27 - if not self.trailing_whitespace.match(line):
28 - return errors.TRAILING_WHITESPACE_ERROR
29
30 + # Check if we're inside a here-document.
31 + if self._here_doc_delim is not None:
32 + if self._here_doc_delim.match(line):
33 + self._here_doc_delim = None
34 + if self._here_doc_delim is None:
35 + here_doc = self.here_doc_re.match(line)
36 + if here_doc is not None:
37 + self._here_doc_delim = re.compile('^%s$' % here_doc.group(1))
38
39 + if self._here_doc_delim is None:
40 + # We're not in a here-document.
41 + if self.leading_spaces.match(line) is None:
42 + return errors.LEADING_SPACES_ERROR
43 + if self.trailing_whitespace.match(line) is None:
44 + return errors.TRAILING_WHITESPACE_ERROR
45 +
46 class EbuildQuote(LineCheck):
47 """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc..."""