def loadConfigFile(file):
import shlex
# read config file
+ linenr = 0
with open(file) as file:
result = AdvancedDict()
curKey = None
for line in file:
+ linenr += 1
isCont = len(line) and line[0].isspace() # remember if we were a continuation line
if isCont and curKey is None:
- raise Exception("Invalid config: Starting with continuation line")
+ raise Exception("Invalid config, line %d: Starting with continuation line" % linenr)
line = line.strip()
if not len(line) or line.startswith("#"): continue # skip empty and comment lines
- if isCont:
- # continuation line
- result[curKey].append(shlex.split(line))
- else:
- # option line
- pos = line.index("=") # will raise exception when substring is not found
- curKey = line[:pos].strip()
- value = line[pos+1:]
- result[curKey] = shlex.split(value)
+ try:
+ if isCont:
+ # continuation line
+ result[curKey] += shlex.split(line)
+ else:
+ # option line
+ pos = line.index("=") # will raise exception when substring is not found
+ curKey = line[:pos].strip()
+ value = line[pos+1:]
+ result[curKey] = shlex.split(value)
+ except Exception:
+ raise Exception("Invalid config, line %d: Error parsing line (quoting issue?)" % linenr)
# add some convencience get functions
return result
print >>f, ""
print >>f, ".PHONY: build" # there may be a directory called "build"
print >>f, ""
- print >>f, "build %:" # need to mention "build" here again explicitly
+ print >>f, "build %:" # need to mention "build" here again explicitly so PHONY takes effect
# write proper dh call
dh = self.dh
if self.dhWith: