aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com>2019-09-03 23:13:25 +0200
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-09-25 22:24:42 +0200
commit6748e42acebe4dfa2221ef508883321f85253ca0 (patch)
tree890b7eb00ae4a7cfdced8966be96c721b30299a9
parentdd99dc576340b8d1bcb046fbaee9b75789b23988 (diff)
downloadbuildroot-6748e42acebe4dfa2221ef508883321f85253ca0.tar.gz
buildroot-6748e42acebe4dfa2221ef508883321f85253ca0.tar.bz2
utils/checkpackagelib: CommentsMenusPackagesOrder: change the type of variable 'level'
Change the type of variable "level" to make it a class member. It will be used not only locally. 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> [Thomas: initialize self.level in the before() method, as suggested by Ricardo] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
-rw-r--r--utils/checkpackagelib/lib_config.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/utils/checkpackagelib/lib_config.py b/utils/checkpackagelib/lib_config.py
index a3fbd0e69e..8f7b13a866 100644
--- a/utils/checkpackagelib/lib_config.py
+++ b/utils/checkpackagelib/lib_config.py
@@ -67,6 +67,7 @@ class CommentsMenusPackagesOrder(_CheckFunction):
def before(self):
self.state = ""
+ self.level = 0
def get_level(self):
return len(self.state.split('-')) - 1
@@ -93,12 +94,12 @@ class CommentsMenusPackagesOrder(_CheckFunction):
elif text.startswith("menu"):
self.state += "-menu"
- level = self.get_level()
+ self.level = self.get_level()
try:
- self.menu_of_packages[level] = text[:-1]
- self.package[level] = ""
- self.print_package_warning[level] = True
+ 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("")
@@ -115,16 +116,16 @@ class CommentsMenusPackagesOrder(_CheckFunction):
self.state = self.state[:-5]
elif source_line:
- level = self.get_level()
+ self.level = self.get_level()
new_package = source_line.group(1)
# We order _ before A, so replace it with .
new_package_ord = new_package.replace('_', '.')
- if self.package[level] != "" and \
- self.print_package_warning[level] and \
- new_package_ord < self.package[level]:
- self.print_package_warning[level] = False
+ if self.package[self.level] != "" and \
+ self.print_package_warning[self.level] and \
+ new_package_ord < self.package[self.level]:
+ self.print_package_warning[self.level] = False
prefix = "{}:{}: ".format(self.filename, lineno)
spaces = " " * len(prefix)
return ["{prefix}Packages in: {menu},\n"
@@ -132,11 +133,11 @@ class CommentsMenusPackagesOrder(_CheckFunction):
"{spaces}correct order: '-', '_', digits, capitals, lowercase;\n"
"{spaces}first incorrect package: {package}"
.format(prefix=prefix, spaces=spaces,
- menu=self.menu_of_packages[level],
+ menu=self.menu_of_packages[self.level],
package=new_package),
text]
- self.package[level] = new_package_ord
+ self.package[self.level] = new_package_ord
class HelpText(_CheckFunction):