Add line number to Augeas syntax error message (#3974)

* Add line number to Augeas syntax error message

* Use `format()` for message formatting

* Pleasing Python 2.6
This commit is contained in:
osirisinferi 2017-01-06 21:58:51 +01:00 committed by Peter Eckersley
parent 1125b4924d
commit f9b8933f37

View file

@ -68,9 +68,12 @@ class AugeasConfigurator(common.Plugin):
# As aug.get may return null
if lens_path and lens in lens_path:
msg = (
"There has been an error in parsing the file (%s): %s",
"There has been an error in parsing the file {0} on line {1}: "
"{2}".format(
# Strip off /augeas/files and /error
path[13:len(path) - 6], self.aug.get(path + "/message"))
path[13:len(path) - 6],
self.aug.get(path + "/line"),
self.aug.get(path + "/message")))
raise errors.PluginError(msg)
# TODO: Cleanup this function