]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - support/scripts/checkpackagelib.py
package/eudev: bump version to 3.2.2
[coffee/buildroot.git] / support / scripts / checkpackagelib.py
1 # See support/scripts/check-package.txt before editing this file.
2
3 from checkpackagebase import _CheckFunction
4
5
6 class ConsecutiveEmptyLines(_CheckFunction):
7     def before(self):
8         self.lastline = "non empty"
9
10     def check_line(self, lineno, text):
11         if text.strip() == "" == self.lastline.strip():
12             return ["{}:{}: consecutive empty lines"
13                     .format(self.filename, lineno)]
14         self.lastline = text
15
16
17 class EmptyLastLine(_CheckFunction):
18     def before(self):
19         self.lastlineno = 0
20         self.lastline = "non empty"
21
22     def check_line(self, lineno, text):
23         self.lastlineno = lineno
24         self.lastline = text
25
26     def after(self):
27         if self.lastline.strip() == "":
28             return ["{}:{}: empty line at end of file"
29                     .format(self.filename, self.lastlineno)]
30
31
32 class NewlineAtEof(_CheckFunction):
33     def before(self):
34         self.lastlineno = 0
35         self.lastline = "\n"
36
37     def check_line(self, lineno, text):
38         self.lastlineno = lineno
39         self.lastline = text
40
41     def after(self):
42         if self.lastline == self.lastline.rstrip("\r\n"):
43             return ["{}:{}: missing newline at end of file"
44                     .format(self.filename, self.lastlineno),
45                     self.lastline]
46
47
48 class TrailingSpace(_CheckFunction):
49     def check_line(self, lineno, text):
50         line = text.rstrip("\r\n")
51         if line != line.rstrip():
52             return ["{}:{}: line contains trailing whitespace"
53                     .format(self.filename, lineno),
54                     text]