Gentoo Archives: gentoo-commits

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