Message ID | 20190611204946.3848-2-jerzy.m.grzegorek@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2,1/2] package/Config.in: fix alphabetical order | expand |
Hi Jerzy, On 11/06/2019 22:49, Jerzy Grzegorek wrote: > Signed-off-by: Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com> Applied both to master, thanks. I still made a lot of changes, though: - calculate level by counting - instead of with a static array; - new_package is only used locally, so don't make it a class member; - do indentation according to length of prefix; - don't split string in the middle of a line; - report first wrong package per menu; - do replace() only once; - add comment why we do replace(). Please take a look at the end result, and if there's something you don't like, send a follow-up patch. Regards, Arnout > --- > Changes v1 -> v2: > - swap patches 1 and 2 (Arnout) > - drop trailing lines (copy/paste side effect) > - rewrap lines to < 80 chars > - add variable to cut lines to < 80 chars > - change alphabetical order of '_" to go before digits (Arnout) > > TODO : checking of menu of comments and menu of menus
Arnout, Jerzy, All, On 2019-07-14 00:27 +0200, Arnout Vandecappelle spake thusly: > On 11/06/2019 22:49, Jerzy Grzegorek wrote: > > Signed-off-by: Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com> > > Applied both to master, thanks. > > I still made a lot of changes, though: > > - calculate level by counting - instead of with a static array; > - new_package is only used locally, so don't make it a class member; > - do indentation according to length of prefix; > - don't split string in the middle of a line; > - report first wrong package per menu; > - do replace() only once; > - add comment why we do replace(). > > Please take a look at the end result, and if there's something you don't like, > send a follow-up patch. This breaks check-package, I'm afraid: $ LC_ALL=C make check-package find /home/ymorin/dev/buildroot/buildroot -type f \( -name '*.mk' -o -name '*.hash' -o -name 'Config.*' \) \ -exec ./utils/check-package {} + Traceback (most recent call last): File "./utils/check-package", line 190, in <module> __main__() File "./utils/check-package", line 173, in __main__ nwarnings, nlines = check_file_using_lib(fname) File "./utils/check-package", line 142, in check_file_using_lib nwarnings += print_warnings(cf.check_line(lineno + 1, text)) File "/home/ymorin/dev/buildroot/buildroot/utils/checkpackagelib/lib_config.py", line 90, in check_line self.package[level] = "" IndexError: list assignment index out of range 36465 lines processed 0 warnings generated package/kodi/Config.in:303: Packages in: menu "Audio decoder addons", are not alphabetically ordered; correct order: '-', '_', digits, capitals, lowercase; first incorrect package: kodi-audiodecoder package/kodi/Config.in:315: Packages in: menu "Audio encoder addons", are not alphabetically ordered; correct order: '-', '_', digits, capitals, lowercase; first incorrect package: kodi-audioencode package/kodi/Config.in:326: Packages in: menu "Inputstream addons", are not alphabetically ordered; correct order: '-', '_', digits, capitals, lowercase; first incorrect package: kodi-inputstream package/kodi/Config.in:335: Packages in: menu "PVR addons", are not alphabetically ordered; correct order: '-', '_', digits, capitals, lowercase; first incorrect package: kodi-pv package/kodi/Config.in:359: Packages in: menu "Screensavers", are not alphabetically ordered; correct order: '-', '_', digits, capitals, lowercase; first incorrect package: kodi-screensaver package/kodi/Config.in:370: Packages in: menu "Visualisations", are not alphabetically ordered; correct order: '-', '_', digits, capitals, lowercase; first incorrect package: kodi-visualisation Traceback (most recent call last): File "./utils/check-package", line 190, in <module> __main__() File "./utils/check-package", line 173, in __main__ nwarnings, nlines = check_file_using_lib(fname) File "./utils/check-package", line 142, in check_file_using_lib nwarnings += print_warnings(cf.check_line(lineno + 1, text)) File "/home/ymorin/dev/buildroot/buildroot/utils/checkpackagelib/lib_config.py", line 90, in check_line self.package[level] = "" IndexError: list assignment index out of range 37453 lines processed 0 warnings generated 20138 lines processed 0 warnings generated make[1]: *** [Makefile:1201: check-package] Error 1 make: *** [Makefile:84: _all] Error 2 So, the kodi errors are all false positive: the ordering there is already correct. But most problematic, is the python traceback, now... :-( Regards, Yann E. MORIN.
Hi Arnout, > Hi Jerzy, > > On 11/06/2019 22:49, Jerzy Grzegorek wrote: >> Signed-off-by: Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com> > Applied both to master, thanks. > > I still made a lot of changes, though: > > - calculate level by counting - instead of with a static array; > - new_package is only used locally, so don't make it a class member; > - do indentation according to length of prefix; > - don't split string in the middle of a line; > - report first wrong package per menu; > - do replace() only once; > - add comment why we do replace(). > > Please take a look at the end result, and if there's something you don't like, > send a follow-up patch. > > Regards, > Arnout I'm fine with all the changes you did. Thanks. However, I'll send a follow-up patch. Regards, Jerzy > > >> --- >> Changes v1 -> v2: >> - swap patches 1 and 2 (Arnout) >> - drop trailing lines (copy/paste side effect) >> - rewrap lines to < 80 chars >> - add variable to cut lines to < 80 chars >> - change alphabetical order of '_" to go before digits (Arnout) >> >> TODO : checking of menu of comments and menu of menus
diff --git a/utils/checkpackagelib/lib_config.py b/utils/checkpackagelib/lib_config.py index 89d44da57e..642634fc44 100644 --- a/utils/checkpackagelib/lib_config.py +++ b/utils/checkpackagelib/lib_config.py @@ -60,6 +60,71 @@ class AttributesOrder(_CheckFunction): text] +class CommentsMenusPackagesOrder(_CheckFunction): + level = {"": 0, + "-menu": 1, "-menu-menu": 2, + "-menu-menu-comment": 3, "-menu-menu-if": 3, "-menu-menu-menu": 3, + "-menu-menu-comment-if": 4, "-menu-menu-if-if": 4, + "-menu-menu-menu-if": 4, "-menu-menu-if-menu": 4, + "-menu-menu-comment-if-comment": 5, "-menu-menu-if-if-comment": 5, + "-menu-menu-if-if-menu": 5, "-menu-menu-menu-if-comment": 5, + "-menu-menu-menu-if-menu": 5} + + print_package_warning = [True, True, True, True, True, True] + menu_of_packages = ["", "", "", "", "", ""] + package = ["", "", "", "", "", ""] + new_package = ["", "", "", "", "", ""] + + def before(self): + self.state = "" + + def check_line(self, lineno, text): + if text.startswith("comment") or text.startswith("if") or \ + text.startswith("menu"): + + if text.startswith("comment"): + if not self.state.endswith("-comment"): + self.state += "-comment" + + elif text.startswith("if") or text.startswith("menu"): + if text.startswith("if"): + self.state += "-if" + + elif text.startswith("menu"): + self.state += "-menu" + + level = self.level[self.state] + self.package[level] = "" + self.print_package_warning[level] = True + self.menu_of_packages[level] = text[:-1] + + elif text.startswith("endif") or text.startswith("endmenu"): + if self.state.endswith("comment"): + self.state = self.state[:-8] + + if text.startswith("endif"): + self.state = self.state[:-3] + + elif text.startswith("endmenu"): + self.state = self.state[:-5] + + elif text.startswith('\tsource "package/'): + level = self.level[self.state] + self.new_package[level] = text[17: -(len(self.filename)-5):] + + if self.package[level] != "" and \ + self.print_package_warning[level] and \ + self.new_package[level].replace('_', '.') < self.package[level].replace('_', '.'): + self.print_package_warning[level] = False + return ["{}:{}: Packages in: {},\n are not " + "alphabetically ordered;\n correct " + "order: '-', '_', digits, capitals, lowercase" + .format(self.filename, lineno, self.menu_of_packages[level]), + text] + + self.package[level] = self.new_package[level] + + class HelpText(_CheckFunction): HELP_TEXT_FORMAT = re.compile("^\t .{,62}$") URL_ONLY = re.compile("^(http|https|git)://\S*$")
Signed-off-by: Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com> --- Changes v1 -> v2: - swap patches 1 and 2 (Arnout) - drop trailing lines (copy/paste side effect) - rewrap lines to < 80 chars - add variable to cut lines to < 80 chars - change alphabetical order of '_" to go before digits (Arnout) TODO : checking of menu of comments and menu of menus --- utils/checkpackagelib/lib_config.py | 65 +++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)