summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-04-30 07:30:22 +0000
committerZac Medico <zmedico@gentoo.org>2009-04-30 07:30:22 +0000
commite6b14780e2f0c88b06b2ec4663b739c8291d7255 (patch)
tree56f14fb523568244a64c05b7d35d70e614d95525
parentMake xtermTitle() use a global variable to cache the result of the TERM check. (diff)
downloadportage-multirepo-e6b14780e2f0c88b06b2ec4663b739c8291d7255.tar.gz
portage-multirepo-e6b14780e2f0c88b06b2ec4663b739c8291d7255.tar.bz2
portage-multirepo-e6b14780e2f0c88b06b2ec4663b739c8291d7255.zip
Make EbuildWhitespace ignore here-documents. Thanks to Diego Pettenò
<flameeyes@g.o> for reporting. (trunk r13411) svn path=/main/branches/2.1.6/; revision=13551
-rw-r--r--pym/repoman/checks.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
index f1dce8b8..075370b6 100644
--- a/pym/repoman/checks.py
+++ b/pym/repoman/checks.py
@@ -71,13 +71,28 @@ class EbuildWhitespace(LineCheck):
ignore_line = re.compile(r'(^$)|(^(\t)*#)')
leading_spaces = re.compile(r'^[\S\t]')
trailing_whitespace = re.compile(r'.*([\S]$)')
+ here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
+
+ def new(self, pkg):
+ self._here_doc_delim = None
def check(self, num, line):
- if not self.leading_spaces.match(line):
- return errors.LEADING_SPACES_ERROR
- if not self.trailing_whitespace.match(line):
- return errors.TRAILING_WHITESPACE_ERROR
+ # Check if we're inside a here-document.
+ if self._here_doc_delim is not None:
+ if self._here_doc_delim.match(line):
+ self._here_doc_delim = None
+ if self._here_doc_delim is None:
+ here_doc = self.here_doc_re.match(line)
+ if here_doc is not None:
+ self._here_doc_delim = re.compile('^%s$' % here_doc.group(1))
+
+ if self._here_doc_delim is None:
+ # We're not in a here-document.
+ if self.leading_spaces.match(line) is None:
+ return errors.LEADING_SPACES_ERROR
+ if self.trailing_whitespace.match(line) is None:
+ return errors.TRAILING_WHITESPACE_ERROR
class EbuildQuote(LineCheck):
"""Ensure ebuilds have valid quoting around things like D,FILESDIR, etc..."""