summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-04-30 07:30:32 +0000
committerZac Medico <zmedico@gentoo.org>2009-04-30 07:30:32 +0000
commit24d263b7f7cdf072f810404d3a436d7a8c39656f (patch)
tree06c5ca9dda142dcdf610deb63894201a728ca3a7
parentMake EbuildWhitespace ignore here-documents. Thanks to Diego Pettenò (diff)
downloadportage-multirepo-24d263b7f7cdf072f810404d3a436d7a8c39656f.tar.gz
portage-multirepo-24d263b7f7cdf072f810404d3a436d7a8c39656f.tar.bz2
portage-multirepo-24d263b7f7cdf072f810404d3a436d7a8c39656f.zip
Move the here-document code from the EbuildWhitespace check to the
run_checks() function, so that all checks ignore the content of here-documents. (trunk r13412) svn path=/main/branches/2.1.6/; revision=13552
-rw-r--r--pym/repoman/checks.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
index 075370b6..732f6eb9 100644
--- a/pym/repoman/checks.py
+++ b/pym/repoman/checks.py
@@ -71,28 +71,12 @@ 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):
-
- # 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
+ 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..."""
@@ -386,18 +370,34 @@ _constant_checks = tuple((c() for c in (
EMakeParallelDisabled, EMakeParallelDisabledViaMAKEOPTS,
DeprecatedBindnowFlags, WantAutoDefaultValue)))
+_here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
+
def run_checks(contents, pkg):
checks = _constant_checks
+ here_doc_delim = None
for lc in checks:
lc.new(pkg)
for num, line in enumerate(contents):
- for lc in checks:
- ignore = lc.ignore_line
- if not ignore or not ignore.match(line):
- e = lc.check(num, line)
- if e:
- yield lc.repoman_check_name, e % (num + 1)
+
+ # Check if we're inside a here-document.
+ if here_doc_delim is not None:
+ if here_doc_delim.match(line):
+ here_doc_delim = None
+ if here_doc_delim is None:
+ here_doc = _here_doc_re.match(line)
+ if here_doc is not None:
+ here_doc_delim = re.compile('^%s$' % here_doc.group(1))
+
+ if here_doc_delim is None:
+ # We're not in a here-document.
+ for lc in checks:
+ ignore = lc.ignore_line
+ if not ignore or not ignore.match(line):
+ e = lc.check(num, line)
+ if e:
+ yield lc.repoman_check_name, e % (num + 1)
+
for lc in checks:
i = lc.end()
if i is not None: