Skip to content

Commit d906229

Browse files
committed
Detect empty config file
1 parent 4333b07 commit d906229

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

lib/config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from collections import UserDict
22
import yaml
33
from pathlib import Path
4-
import glob
54
import re
65
import os
7-
import subprocess
86

97

108
def get_queries(path):
@@ -20,19 +18,20 @@ def get_queries(path):
2018

2119
class Config(UserDict):
2220
def __init__(self, file=None, debug=False):
21+
self.data = {}
2322
if file:
2423
try:
2524
with open(file) as stream:
2625
self.data = yaml.safe_load(stream)
26+
if not self.data:
27+
self.data = {}
2728
except yaml.YAMLError as err:
2829
msg = "Error in %s" % (file)
2930
if hasattr(err, 'problem_mark'):
3031
mark = err.problem_mark
3132
msg += " at line %s char %s" % (mark.line + 1,
3233
mark.column + 1)
3334
raise Exception(msg)
34-
else:
35-
self.data = {}
3635

3736
self.data["stage"] = os.getenv('STAGE', 'stage')
3837
self.data["sparql"] = os.getenv('SPARQL', "http://localhost:3030/n4o")

0 commit comments

Comments
 (0)