From 3bf2b10ae0bef28677ea0ab3e2d1bbb3fe31735f Mon Sep 17 00:00:00 2001 From: pommicket Date: Tue, 23 Sep 2025 13:31:00 -0400 Subject: Clean up examples, fix a few bugs --- examples/read_conf.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'examples/read_conf.py') diff --git a/examples/read_conf.py b/examples/read_conf.py index bbee83b..4f6bf56 100644 --- a/examples/read_conf.py +++ b/examples/read_conf.py @@ -6,9 +6,21 @@ import sys sys.path.append(str(Path(__file__).parent.parent)) import pom_parser + +filename = 'examples/conf.pom' if len(sys.argv) < 2 else sys.argv[1] try: - filename = 'examples/conf.pom' if len(sys.argv) < 2 else sys.argv[1] + # Load configuration from file conf = pom_parser.load_path(filename) - print(conf.location('file-extensions')) except pom_parser.Error as e: - print('Parse error:', str(e), sep = '\n') + # Handle error due to invalid configuration file + print('Parse error:\n' + str(e)) + sys.exit(1) + +# Get value of key in configuration +indentation_type = conf.get('indentation-type') +if indentation_type is not None: + # Key is set + print('Indenting with', indentation_type) +else: + # Key is not set + print('No indentation type specified') -- cgit v1.2.3