in src/pycalendar/vcard/card.py [0:0]
def parseMultipleTextData(cls, ins):
if isinstance(ins, str):
ins = StringIO(ins)
results = []
card = cls(add_defaults=False)
LOOK_FOR_VCARD = 0
GET_PROPERTY = 1
state = LOOK_FOR_VCARD
# Get lines looking for start of calendar
lines = [None, None]
while readFoldedLine(ins, lines):
line = lines[0]
if state == LOOK_FOR_VCARD:
# Look for start
if line == card.getBeginDelimiter():
# Next state
state = GET_PROPERTY
# Handle blank line
elif len(line) == 0:
# Raise if requested, otherwise just ignore
if ParserContext.BLANK_LINES_IN_DATA == ParserContext.PARSER_RAISE:
raise InvalidData("vCard data has blank lines")
# Unrecognized data
else:
raise InvalidData("vCard data not recognized", line)
elif state == GET_PROPERTY:
# Look for end of object
if line == card.getEndDelimiter():
# Finalise the current calendar
card.finalise()
# Validate some things
if not card.hasProperty("VERSION"):
raise InvalidData("vCard missing VERSION", "")
results.append(card)
# Change state
card = Card(add_defaults=False)
state = LOOK_FOR_VCARD
# Blank line
elif len(line) == 0:
# Raise if requested, otherwise just ignore
if ParserContext.BLANK_LINES_IN_DATA == ParserContext.PARSER_RAISE:
raise InvalidData("vCard data has blank lines")
# Must be a property
else:
# Parse parameter/value for top-level calendar item
prop = Property.parseText(line)
# Check for valid property
if not card.validProperty(prop):
raise InvalidData("Invalid property", str(prop))
else:
card.addProperty(prop)
# Check for truncated data
if state != LOOK_FOR_VCARD:
raise InvalidData("vCard data not complete")
return results