284
284
# rather than a more specific error.
286
286
for line in unicode_iter:
287
if line is None or line == '':
287
if line is None or line == u'':
288
288
break # end of file
290
290
break # end of stanza
292
if line[0] == '\t': # continues previous value
292
if line[0] == u'\t': # continues previous value
294
294
raise ValueError('invalid continuation line %r' % real_l)
295
accum_value += '\n' + line[1:-1]
295
accum_value.append(u'\n' + line[1:-1])
296
296
else: # new tag:value line
297
297
if tag is not None:
298
stanza.add(tag, accum_value)
298
stanza.add(tag, u''.join(accum_value))
300
colon_index = line.index(': ')
300
colon_index = line.index(u': ')
301
301
except ValueError:
302
302
raise ValueError('tag/value separator not found in line %r'
304
304
tag = str(line[:colon_index])
305
305
if not valid_tag(tag):
306
306
raise ValueError("invalid rio tag %r" % (tag,))
307
accum_value = line[colon_index+2:-1]
307
accum_value = [line[colon_index+2:-1]]
309
309
if tag is not None: # add last tag-value
310
stanza.add(tag, accum_value)
310
stanza.add(tag, u''.join(accum_value))
312
312
else: # didn't see any content