def parse(self, record, rid): """Parse everything from a string""" # Split up into lines Encoding.check_unicode(record) split_lines = record.split("\n") self.check_line_length(split_lines, rid) self.maybe_remove_last_empty_line(split_lines) self.comment_raw = TxtParser.extract_record_comment(split_lines) for comment in self.comment_raw: Encoding.check_unicode(comment) self.set_comment(TxtParser.extract_comment(self.comment_raw)) Encoding.check_unicode(self.get_comment()) success, parsed_record = TxtParser.split_entries( split_lines, rid, self, len(self.comment_raw) + 1) # If there was an error during the split already - stop # processing here if not success: self._set_not_usable() return for i in parsed_record: self.append(TxtRecordEntry(i)) return
def parse(self, s, rid): # Split up into lines sl = s.split("\n") self.check_line_length(sl, rid) self.maybe_remove_last_empty_line(sl) self.comment_raw = TxtParser.extract_record_comment(sl) self.set_comment(TxtParser.extract_comment(self.comment_raw)) success, rp = TxtParser.split_entries(sl, rid, self, len(self.comment_raw) + 1) # If there was an error during the split already - stop # processing here if not success: self.set_unusable() return for i in rp: self.append(TxtRecordEntry(i)) return
def parse(self, s, rid): # Split up into lines sl = s.split("\n") self.check_line_length(sl, rid) self.maybe_remove_last_empty_line(sl) self.comment_raw = TxtParser.extract_record_comment(sl) self.set_comment(TxtParser.extract_comment(self.comment_raw)) success, rp = TxtParser.split_entries(sl, rid, self, len(self.comment_raw) + 1) # If there was an error during the split already - stop # processing here if not success: self._set_not_usable() return for i in rp: self.append(TxtRecordEntry(i)) return