diff options
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') |