mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
parent
d63b63f7f9
commit
c739bbfcac
1 changed files with 16 additions and 12 deletions
|
|
@ -236,19 +236,23 @@ class _Component(object):
|
||||||
|
|
||||||
stack = []
|
stack = []
|
||||||
rv = []
|
rv = []
|
||||||
for line in lines:
|
try:
|
||||||
if line.startswith(u'BEGIN:'):
|
for i, line in enumerate(lines):
|
||||||
c_name = line[len(u'BEGIN:'):].strip().upper()
|
if line.startswith(u'BEGIN:'):
|
||||||
stack.append(cls(c_name, [], []))
|
c_name = line[len(u'BEGIN:'):].strip().upper()
|
||||||
elif line.startswith(u'END:'):
|
stack.append(cls(c_name, [], []))
|
||||||
component = stack.pop()
|
elif line.startswith(u'END:'):
|
||||||
if stack:
|
component = stack.pop()
|
||||||
stack[-1].subcomponents.append(component)
|
if stack:
|
||||||
|
stack[-1].subcomponents.append(component)
|
||||||
|
else:
|
||||||
|
rv.append(component)
|
||||||
else:
|
else:
|
||||||
rv.append(component)
|
if line.strip():
|
||||||
else:
|
stack[-1].props.append(line)
|
||||||
if line.strip():
|
except IndexError:
|
||||||
stack[-1].props.append(line)
|
raise ValueError('Parsing error at line {}. Check the debug log '
|
||||||
|
'for more information.'.format(i + 1))
|
||||||
|
|
||||||
if multiple:
|
if multiple:
|
||||||
return rv
|
return rv
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue