Logo Search packages:      
Sourcecode: radicale version File versions  Download package

def radicale::ical::Calendar::_parse (   text,
  item_types,
  name = None 
) [private]
Find items with type in ``item_types`` in ``text`` text.

If ``name`` is given, give this name to new items in ``text``.

Return a list of items.

Definition at line 145 of file ical.py.

                                           :
        """Find items with type in ``item_types`` in ``text`` text.

        If ``name`` is given, give this name to new items in ``text``.

        Return a list of items.

        """
        item_tags = {}
        for item_type in item_types:
            item_tags[item_type.tag] = item_type

        items = []

        lines = text.splitlines()
        in_item = False

        for line in lines:
            if line.startswith("BEGIN:") and not in_item:
                item_tag = line.replace("BEGIN:", "").strip()
                if item_tag in item_tags:
                    in_item = True
                    item_lines = []

            if in_item:
                item_lines.append(line)
                if line.startswith("END:%s" % item_tag):
                    in_item = False
                    item_type = item_tags[item_tag]
                    item_text = "\n".join(item_lines)
                    item_name = None if item_tag == "VTIMEZONE" else name
                    items.append(item_type(item_text, item_name))

        return items


Generated by  Doxygen 1.6.0   Back to index