mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 05:36:32 +00:00
utils/check-package: allow to disable warning for a line
Currently any exceptions for a check function need to be coded into the check-package script itself. Create a pattern that can be used in a comment to make check-package ignore one or more warning types in the line immediately below: # check-package Indent, VariableWithBraces Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
parent
908a8b5a7f
commit
4a6c5ab2c3
@ -132,10 +132,14 @@ def check_file_using_lib(fname):
|
|||||||
f = open(fname, "r", errors="surrogateescape")
|
f = open(fname, "r", errors="surrogateescape")
|
||||||
else:
|
else:
|
||||||
f = open(fname, "r")
|
f = open(fname, "r")
|
||||||
|
lastline = ""
|
||||||
for lineno, text in enumerate(f.readlines()):
|
for lineno, text in enumerate(f.readlines()):
|
||||||
nlines += 1
|
nlines += 1
|
||||||
for cf in objects:
|
for cf in objects:
|
||||||
|
if cf.disable.search(lastline):
|
||||||
|
continue
|
||||||
nwarnings += print_warnings(cf.check_line(lineno + 1, text))
|
nwarnings += print_warnings(cf.check_line(lineno + 1, text))
|
||||||
|
lastline = text
|
||||||
f.close()
|
f.close()
|
||||||
for cf in objects:
|
for cf in objects:
|
||||||
nwarnings += print_warnings(cf.after())
|
nwarnings += print_warnings(cf.after())
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
# See utils/checkpackagelib/readme.txt before editing this file.
|
# See utils/checkpackagelib/readme.txt before editing this file.
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
class _CheckFunction(object):
|
class _CheckFunction(object):
|
||||||
def __init__(self, filename, url_to_manual):
|
def __init__(self, filename, url_to_manual):
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.url_to_manual = url_to_manual
|
self.url_to_manual = url_to_manual
|
||||||
|
self.disable = re.compile(r"^\s*# check-package .*\b{}\b".format(self.__class__.__name__))
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user