aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com>2019-09-03 23:13:27 +0200
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-09-25 22:24:42 +0200
commit7197d3cb807baefc4840dd6b636b00bbdfc5cdf5 (patch)
tree6cefc5448e2fa1139ebab0c737bf1a576ef12a6c
parent4e88b372744a8ccd29b6a4a44add6870aa0ed6b5 (diff)
downloadbuildroot-7197d3cb807baefc4840dd6b636b00bbdfc5cdf5.tar.gz
buildroot-7197d3cb807baefc4840dd6b636b00bbdfc5cdf5.tar.bz2
utils/checkpackagelib: CommentsMenusPackagesOrder: add functions to initialize arrays elements
Factor out two functions to initialize arrays elements. They will be reused by followup patches. Signed-off-by: Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com> Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Reviewed-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
-rw-r--r--utils/checkpackagelib/lib_config.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/utils/checkpackagelib/lib_config.py b/utils/checkpackagelib/lib_config.py
index d12653f080..aaa31e4d72 100644
--- a/utils/checkpackagelib/lib_config.py
+++ b/utils/checkpackagelib/lib_config.py
@@ -72,6 +72,20 @@ class CommentsMenusPackagesOrder(_CheckFunction):
def get_level(self):
return len(self.state.split('-')) - 1
+ def initialize_package_level_elements(self, text):
+ try:
+ self.menu_of_packages[self.level] = text[:-1]
+ self.package[self.level] = ""
+ self.print_package_warning[self.level] = True
+ except IndexError:
+ self.menu_of_packages.append(text[:-1])
+ self.package.append("")
+ self.print_package_warning.append(True)
+
+ def initialize_level_elements(self, text):
+ self.level = self.get_level()
+ self.initialize_package_level_elements(text)
+
def check_line(self, lineno, text):
# We only want to force sorting for the top-level menus
if self.filename not in ["package/Config.in",
@@ -94,16 +108,7 @@ class CommentsMenusPackagesOrder(_CheckFunction):
elif text.startswith("menu"):
self.state += "-menu"
- self.level = self.get_level()
-
- try:
- self.menu_of_packages[self.level] = text[:-1]
- self.package[self.level] = ""
- self.print_package_warning[self.level] = True
- except IndexError:
- self.menu_of_packages.append(text[:-1])
- self.package.append("")
- self.print_package_warning.append(True)
+ self.initialize_level_elements(text)
elif text.startswith("endif") or text.startswith("endmenu"):
if self.state.endswith("comment"):