checkpackagelib.py 567 B

12345678910111213141516171819
  1. # See support/scripts/check-package.txt before editing this file.
  2. from checkpackagebase import _CheckFunction
  3. class NewlineAtEof(_CheckFunction):
  4. def before(self):
  5. self.lastlineno = 0
  6. self.lastline = "\n"
  7. def check_line(self, lineno, text):
  8. self.lastlineno = lineno
  9. self.lastline = text
  10. def after(self):
  11. if self.lastline == self.lastline.rstrip("\r\n"):
  12. return ["{}:{}: missing newline at end of file"
  13. .format(self.filename, self.lastlineno),
  14. self.lastline]