Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13412 - main/trunk/pym/repoman
Date: Wed, 29 Apr 2009 19:13:18
Message-Id: E1LzFDY-00027G-21@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-04-29 19:13:15 +0000 (Wed, 29 Apr 2009)
3 New Revision: 13412
4
5 Modified:
6 main/trunk/pym/repoman/checks.py
7 Log:
8 Move the here-document code from the EbuildWhitespace check to the
9 run_checks() function, so that all checks ignore the content of
10 here-documents.
11
12
13 Modified: main/trunk/pym/repoman/checks.py
14 ===================================================================
15 --- main/trunk/pym/repoman/checks.py 2009-04-29 18:27:55 UTC (rev 13411)
16 +++ main/trunk/pym/repoman/checks.py 2009-04-29 19:13:15 UTC (rev 13412)
17 @@ -71,29 +71,13 @@
18 ignore_line = re.compile(r'(^$)|(^(\t)*#)')
19 leading_spaces = re.compile(r'^[\S\t]')
20 trailing_whitespace = re.compile(r'.*([\S]$)')
21 - here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
22
23 - def new(self, pkg):
24 - self._here_doc_delim = None
25 -
26 def check(self, num, line):
27 + if self.leading_spaces.match(line) is None:
28 + return errors.LEADING_SPACES_ERROR
29 + if self.trailing_whitespace.match(line) is None:
30 + return errors.TRAILING_WHITESPACE_ERROR
31
32 - # Check if we're inside a here-document.
33 - if self._here_doc_delim is not None:
34 - if self._here_doc_delim.match(line):
35 - self._here_doc_delim = None
36 - if self._here_doc_delim is None:
37 - here_doc = self.here_doc_re.match(line)
38 - if here_doc is not None:
39 - self._here_doc_delim = re.compile('^%s$' % here_doc.group(1))
40 -
41 - if self._here_doc_delim is None:
42 - # We're not in a here-document.
43 - if self.leading_spaces.match(line) is None:
44 - return errors.LEADING_SPACES_ERROR
45 - if self.trailing_whitespace.match(line) is None:
46 - return errors.TRAILING_WHITESPACE_ERROR
47 -
48 class EbuildQuote(LineCheck):
49 """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc..."""
50
51 @@ -386,18 +370,34 @@
52 EMakeParallelDisabled, EMakeParallelDisabledViaMAKEOPTS,
53 DeprecatedBindnowFlags, WantAutoDefaultValue)))
54
55 +_here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
56 +
57 def run_checks(contents, pkg):
58 checks = _constant_checks
59 + here_doc_delim = None
60
61 for lc in checks:
62 lc.new(pkg)
63 for num, line in enumerate(contents):
64 - for lc in checks:
65 - ignore = lc.ignore_line
66 - if not ignore or not ignore.match(line):
67 - e = lc.check(num, line)
68 - if e:
69 - yield lc.repoman_check_name, e % (num + 1)
70 +
71 + # Check if we're inside a here-document.
72 + if here_doc_delim is not None:
73 + if here_doc_delim.match(line):
74 + here_doc_delim = None
75 + if here_doc_delim is None:
76 + here_doc = _here_doc_re.match(line)
77 + if here_doc is not None:
78 + here_doc_delim = re.compile('^%s$' % here_doc.group(1))
79 +
80 + if here_doc_delim is None:
81 + # We're not in a here-document.
82 + for lc in checks:
83 + ignore = lc.ignore_line
84 + if not ignore or not ignore.match(line):
85 + e = lc.check(num, line)
86 + if e:
87 + yield lc.repoman_check_name, e % (num + 1)
88 +
89 for lc in checks:
90 i = lc.end()
91 if i is not None: