From 136040e64f40707058ef660e7932f187b86ae06e Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 29 Apr 2009 18:27:55 +0000 Subject: =?UTF-8?q?Make=20EbuildWhitespace=20ignore=20here-documents.=20Th?= =?UTF-8?q?anks=20to=20Diego=20Petten=C3=B2=20=20for=20repo?= =?UTF-8?q?rting.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/main/trunk/; revision=13411 --- pym/repoman/checks.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'pym/repoman/checks.py') diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index f1dce8b89..075370b6b 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...""" -- cgit v1.2.3-1-g7c22