@@ -146,7 +146,7 @@ def _set_options_from_file(self, file_handle):
146146 """
147147
148148 # TODO: Find a library to handle this unit file parsing
149- # Can't use configparser, it doesn't handle multiple entries for the same key in the same sectoin
149+ # Can't use configparser, it doesn't handle multiple entries for the same key in the same section
150150 # This is terribly naive
151151
152152 # build our output here
@@ -161,6 +161,7 @@ def _set_options_from_file(self, file_handle):
161161 line_number += 1
162162
163163 # clear any extra white space
164+ orig_line = line
164165 line = line .strip ()
165166
166167 # ignore comments, and blank lines
@@ -183,8 +184,25 @@ def _set_options_from_file(self, file_handle):
183184 ))
184185
185186 # Attempt to parse a line inside a section
186- # Lines should look like: name=value
187+ # Lines should look like: name=value \
188+ # continuation
189+ continuation = False
187190 try :
191+ # if the previous value ends with \ then we are a continuation
192+ # so remove the \, and set the flag so we'll append to this below
193+ if options [- 1 ]['value' ].endswith ('\\ ' ):
194+ options [- 1 ]['value' ] = options [- 1 ]['value' ][:- 1 ]
195+ continuation = True
196+ except IndexError :
197+ pass
198+
199+ try :
200+ # if we are a continuation, then just append our value to the previous line
201+ if continuation :
202+ options [- 1 ]['value' ] += orig_line
203+ continue
204+
205+ # else we are a normal line, so spit and get our name / value
188206 name , value = line .split ('=' , 1 )
189207 options .append ({
190208 'section' : section ,
@@ -194,7 +212,7 @@ def _set_options_from_file(self, file_handle):
194212 except ValueError :
195213 raise ValueError (
196214 'Unable to parse unit file; '
197- 'Malformed line in section {0}: {1} (line: {2}' .format (
215+ 'Malformed line in section {0}: {1} (line: {2}) ' .format (
198216 section ,
199217 line ,
200218 line_number
0 commit comments