Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isccfg manual running mode #1125

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions repos/system_upgrade/el7toel8/libraries/isccfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# Simplified parsing of bind configuration, with include support and nested sections.

from __future__ import print_function

import re
import string

Expand Down Expand Up @@ -948,3 +950,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)