From 5b1ca668dfc67e73b451cddaa4731b65e921d8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Wed, 30 Aug 2023 16:58:45 +0200 Subject: [PATCH 1/2] Add isccfg library manual running mode For simplified manual testing add waking mode to parser script. Allows direct test run displaying just chosen statements or blocks. --- .../el7toel8/libraries/isccfg.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/repos/system_upgrade/el7toel8/libraries/isccfg.py b/repos/system_upgrade/el7toel8/libraries/isccfg.py index dff9bf24e4..1d29ff21d4 100644 --- a/repos/system_upgrade/el7toel8/libraries/isccfg.py +++ b/repos/system_upgrade/el7toel8/libraries/isccfg.py @@ -948,3 +948,31 @@ def load_config(self, path=None): self.load_main_config() self.load_included_files() pass + + +if __name__ == '__main__': + """Run parser to default path or path in the first argument. + + Additional parameters are statements or blocks to print. + Defaults to options and zone. + """ + + from sys import argv + + def print_cb(section, state): + print(section) + + cfgpath = IscConfigParser.CONFIG_FILE + if len(argv) > 1: + cfgpath = argv[1] + if len(argv) > 2: + cb = {} + for key in argv[2:]: + cb[key] = print_cb + else: + cb = {'options': print_cb, 'zone': print_cb} + + parser = IscConfigParser(cfgpath) + for section in parser.FILES_TO_CHECK: + print("# Walking file '{}'".format(section.path)) + parser.walk(section.root_section(), cb) From 91db1e9f035d4c0706feb85def7685a535167ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Thu, 31 Aug 2023 13:04:34 +0200 Subject: [PATCH 2/2] Avoid warnings on python2 Use python3 compatible print function --- repos/system_upgrade/el7toel8/libraries/isccfg.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repos/system_upgrade/el7toel8/libraries/isccfg.py b/repos/system_upgrade/el7toel8/libraries/isccfg.py index 1d29ff21d4..45baba0b8c 100644 --- a/repos/system_upgrade/el7toel8/libraries/isccfg.py +++ b/repos/system_upgrade/el7toel8/libraries/isccfg.py @@ -2,6 +2,8 @@ # # Simplified parsing of bind configuration, with include support and nested sections. +from __future__ import print_function + import re import string