diff options
author | pommicket <pommicket@gmail.com> | 2025-09-23 13:31:00 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2025-09-23 13:31:00 -0400 |
commit | 3bf2b10ae0bef28677ea0ab3e2d1bbb3fe31735f (patch) | |
tree | f70dde9c5bcf1f6aae39ea609620ed8e8ca186d3 /examples/read_conf.py | |
parent | 6407cf22def09de43ec2ec02692c0e4ea3b17742 (diff) |
Clean up examples, fix a few bugsv0.0.1
Diffstat (limited to 'examples/read_conf.py')
-rw-r--r-- | examples/read_conf.py | 18 |
1 files changed, 15 insertions, 3 deletions
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') |