Skip to content

Commit

Permalink
Add isccfg library manual running mode
Browse files Browse the repository at this point in the history
For simplified manual testing add waking mode to parser script. Allows
direct test run displaying just chosen statements or blocks.
  • Loading branch information
pemensik committed Aug 30, 2023
1 parent 93c6fd4 commit 6faaca3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions repos/system_upgrade/el7toel8/libraries/isccfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6faaca3

Please sign in to comment.