Exemplo n.º 1
0
    def _parseObject(self, item):
        parser = ical.VCalendarParser()
        parser.parse(map(lambda x: x.rstrip("\r"), item.data.strip().split("\n")))
        categories = parser.notes[0].pop("categories", [])

        kwargs = dict([(k, v) for k, v in parser.notes[0].items() if k in ["subject", "description", "id"]])
        note = Note(**kwargs)

        for category in categories:
            categoryObject = self.categoryList.findCategoryByName(category)
            if categoryObject is None:
                categoryObject = Category(category)
                self.categoryList.extend([categoryObject])
            note.addCategory(categoryObject)

        return note
Exemplo n.º 2
0
    def _parseObject(self, item):
        data = item.data.decode('UTF-8')
        idx = data.find('\n')
        if idx == -1:
            subject = data
            description = u''
        else:
            subject = data[:idx].rstrip('\r')
            description = data[idx + 1:]

        return Note(subject=subject, description=description)
Exemplo n.º 3
0
    def _parseObject(self, item):
        # Horde doesn't seem to give a f**k about the supported types we send it.
        if item.dataType == 'text/plain':
            lines = map(lambda x: x.rstrip('\r'), item.data.split('\n'))
            kwargs = dict(subject=lines[0], description='\n'.join(lines[1:])) if lines else dict()
            categories = list()
        else:
            parser = ical.VCalendarParser()
            parser.parse(map(lambda x: x.rstrip('\r'), item.data.strip().split('\n')))
            categories = parser.notes[0].pop('categories', [])

            kwargs = dict([(k, v) for k, v in parser.notes[0].items() if k in ['subject', 'description', 'id']])

        note = Note(**kwargs)
        for category in categories:
            categoryObject = self.categoryList.findCategoryByName(category)
            if categoryObject is None:
                categoryObject = Category(category)
                self.categoryList.extend([categoryObject])
            note.addCategory(categoryObject)
        return note
Exemplo n.º 4
0
    def _parseObject(self, item):
        # Horde doesn't seem to give a f**k about the supported types we send it.
        if item.dataType == 'text/plain':
            lines = map(lambda x: x.rstrip('\r'), item.data.split('\n'))
            kwargs = dict(subject=lines[0], description='\n'.join(lines[1:])) if lines else dict()
            categories = list()
        else:
            parser = ical.VCalendarParser()
            parser.parse(map(lambda x: x.rstrip('\r'), item.data.strip().split('\n')))
            categories = parser.notes[0].pop('categories', [])

            kwargs = dict([(k, v) for k, v in parser.notes[0].items() if k in ['subject', 'description', 'id']])

        note = Note(**kwargs)
        for category in categories:
            categoryObject = self.categoryList.findCategoryByName(category)
            if categoryObject is None:
                categoryObject = Category(category)
                self.categoryList.extend([categoryObject])
            note.addCategory(categoryObject)
        return note