summaryrefslogtreecommitdiffstats
path: root/support/scripts/checkpackagelib_config.py
diff options
context:
space:
mode:
authorRicardo Martincoski <ricardo.martincoski@gmail.com>2017-04-19 15:06:21 -0300
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-04-20 22:29:41 +0200
commit7b394c4926dcb860a356eeb46b1f1f5d807041f7 (patch)
tree0b61db0b8f7433dc1c2619ab3f0353201c84bcd0 /support/scripts/checkpackagelib_config.py
parent33481124c7913fbdaee327afd97fd8ba138434e6 (diff)
downloadbuildroot-7b394c4926dcb860a356eeb46b1f1f5d807041f7.tar.gz
buildroot-7b394c4926dcb860a356eeb46b1f1f5d807041f7.zip
check-package: move parts to subdirectory
Currently the check-package script uses many files in the same directory. This commit keeps the main script in support/scripts/ and moves the rest into a subdirectory. The modules were previously prefixed to make it easy to identify which script they belong to. This is no longer needed when using a subdirectory, so the prefix is removed. Note: if this commit is checked out and the script is run, and later on a previous version is checked out, the file support/scripts/checkpackagelib/__init__.pyc needs to be manually removed to prevent Python interpreter to look for checkpackagelib package when only the checkpackagelib module is available. Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support/scripts/checkpackagelib_config.py')
-rw-r--r--support/scripts/checkpackagelib_config.py138
1 files changed, 0 insertions, 138 deletions
diff --git a/support/scripts/checkpackagelib_config.py b/support/scripts/checkpackagelib_config.py
deleted file mode 100644
index be52d94327..0000000000
--- a/support/scripts/checkpackagelib_config.py
+++ /dev/null
@@ -1,138 +0,0 @@
-# See support/scripts/check-package.txt before editing this file.
-# Kconfig generates errors if someone introduces a typo like "boool" instead of
-# "bool", so below check functions don't need to check for things already
-# checked by running "make menuconfig".
-
-import re
-
-from checkpackagebase import _CheckFunction
-# Notice: ignore 'imported but unused' from pyflakes for check functions.
-from checkpackagelib import ConsecutiveEmptyLines
-from checkpackagelib import EmptyLastLine
-from checkpackagelib import NewlineAtEof
-from checkpackagelib import TrailingSpace
-
-
-def _empty_or_comment(text):
- line = text.strip()
- # ignore empty lines and comment lines indented or not
- return line == "" or line.startswith("#")
-
-
-def _part_of_help_text(text):
- return text.startswith("\t ")
-
-
-# used in more than one check
-entries_that_should_not_be_indented = [
- "choice", "comment", "config", "endchoice", "endif", "endmenu", "if",
- "menu", "menuconfig", "source"]
-
-
-class AttributesOrder(_CheckFunction):
- attributes_order_convention = {
- "bool": 1, "prompt": 1, "string": 1, "default": 2, "depends": 3,
- "select": 4, "help": 5}
-
- def before(self):
- self.state = 0
-
- def check_line(self, lineno, text):
- if _empty_or_comment(text) or _part_of_help_text(text):
- return
-
- attribute = text.split()[0]
-
- if attribute in entries_that_should_not_be_indented:
- self.state = 0
- return
- if attribute not in self.attributes_order_convention.keys():
- return
- new_state = self.attributes_order_convention[attribute]
- wrong_order = self.state > new_state
-
- # save to process next line
- self.state = new_state
-
- if wrong_order:
- return ["{}:{}: attributes order: type, default, depends on,"
- " select, help ({}#_config_files)"
- .format(self.filename, lineno, self.url_to_manual),
- text]
-
-
-class HelpText(_CheckFunction):
- HELP_TEXT_FORMAT = re.compile("^\t .{,62}$")
- URL_ONLY = re.compile("^(http|https|git)://\S*$")
-
- def before(self):
- self.help_text = False
-
- def check_line(self, lineno, text):
- if _empty_or_comment(text):
- return
-
- entry = text.split()[0]
-
- if entry in entries_that_should_not_be_indented:
- self.help_text = False
- return
- if text.strip() == "help":
- self.help_text = True
- return
-
- if not self.help_text:
- return
-
- if self.HELP_TEXT_FORMAT.match(text.rstrip()):
- return
- if self.URL_ONLY.match(text.strip()):
- return
- return ["{}:{}: help text: <tab><2 spaces><62 chars>"
- " ({}#writing-rules-config-in)"
- .format(self.filename, lineno, self.url_to_manual),
- text,
- "\t " + "123456789 " * 6 + "12"]
-
-
-class Indent(_CheckFunction):
- ENDS_WITH_BACKSLASH = re.compile(r"^[^#].*\\$")
- entries_that_should_be_indented = [
- "bool", "default", "depends", "help", "prompt", "select", "string"]
-
- def before(self):
- self.backslash = False
-
- def check_line(self, lineno, text):
- if _empty_or_comment(text) or _part_of_help_text(text):
- self.backslash = False
- return
-
- entry = text.split()[0]
-
- last_line_ends_in_backslash = self.backslash
-
- # calculate for next line
- if self.ENDS_WITH_BACKSLASH.search(text):
- self.backslash = True
- else:
- self.backslash = False
-
- if last_line_ends_in_backslash:
- if text.startswith("\t"):
- return
- return ["{}:{}: continuation line should be indented using tabs"
- .format(self.filename, lineno),
- text]
-
- if entry in self.entries_that_should_be_indented:
- if not text.startswith("\t{}".format(entry)):
- return ["{}:{}: should be indented with one tab"
- " ({}#_config_files)"
- .format(self.filename, lineno, self.url_to_manual),
- text]
- elif entry in entries_that_should_not_be_indented:
- if not text.startswith(entry):
- return ["{}:{}: should not be indented"
- .format(self.filename, lineno),
- text]
OpenPOWER on IntegriCloud