예제 #1
0
    def export_collection_memberships(self, collection):
        eim_wrapped = eim.EIM(collection)
        collection_id = eim_wrapped.well_known_name or eim_wrapped.uuid

        for item in collection.items:
            yield model.CollectionMembershipRecord(
                collection_id,
                eim.EIM(item).uuid,
                eim.NoChange,
            )
예제 #2
0
파일: main.py 프로젝트: ra2003/chandler2
def uuids_to_export():
    """Add the EIM extension to sidebar_entries, return uuids to export."""
    from chandler.sharing import eim
    uuids = []
    for entry in ChandlerApplication.sidebar_entries:
        eim_entry = eim.EIM(entry.collection)
        if not eim.EIM.installed_on(entry.collection):
            eim_entry.add()
        uuids.append(eim_entry.well_known_name or eim_entry.uuid)
        for item in entry.collection.items:
            # this exports items in the collections, but not modifications
            eim_item = eim.EIM(item)
            if not eim.EIM.installed_on(eim_item):
                eim_item.add()
            uuids.append(eim_item.uuid)
    return uuids
예제 #3
0
    def import_keyword(self, record):
        keyword = keyword_for_id(record.keywordID)
        if not eim.EIM.installed_on(keyword):
            eim.EIM(keyword).add()
        for sidebar_entry in ChandlerApplication.sidebar_entries:
            if sidebar_entry.collection is keyword:
                break
        else:
            sidebar_entry = SidebarEntry(collection=keyword)
            ChandlerApplication.sidebar_entries.add(sidebar_entry)

        hsv = self.record_rgb_to_hsv(record)
        if hsv:
            sidebar_entry.hsv_color = hsv
예제 #4
0
    def export_item(self, item):
        mask = SharingMask(item)

        triage = Triage(item)
        recurring = Recurrence.installed_on(item) and Recurrence(item).rruleset
        if recurring:
            encoded_triage = eim.NoChange
        elif triage.manual and triage.manual_timestamp:
            code = normalize_triage_code(triage.manual)
            manual_timestamp = -1 * triage.manual_timestamp
            encoded_triage = "%s %.2f 0" % (code, manual_timestamp)
        else:
            encoded_triage = eim.Inherit

        yield model.ItemRecord(
            item,  # uuid
            self.obfuscate(mask.title),  # title
            encoded_triage,  # triage
            with_nochange(mask.created, decimal_int),  # createdOn
            eim.NoChange,  # hasBeenSent
            eim.NoChange,  # needsReply
            eim.NoChange,  # read
        )

        eim_wrapped = eim.EIM(item)

        yield model.NoteRecord(
            item,  # uuid
            self.obfuscate(mask.body),  # body
            empty_as_inherit(eim_wrapped, 'ical_uid'),  # icalUid
            eim.Inherit,  # icalendarProperties
            eim.Inherit,  # icalendarParameters
            empty_as_inherit(eim_wrapped, 'ical_extra')  # icalendarExtra
        )

        if not ReminderList(item).reminders:
            description = None
            trigger = None
            duration = None
            repeat = None

        elif not getattr(item, 'recurrence_id', False):
            reminder = ReminderList(item).reminders[0]
            trigger = None
            if reminder.delta:
                trigger = timedeltaToString(reminder.delta)
            elif reminder.fixed_trigger:
                fixed = reminder.fixed_trigger.astimezone(TimeZone.utc)
                trigger = toICalendarDateTime(fixed, False)

            duration = eim.NoChange
            repeat = eim.NoChange
            description = getattr(reminder, 'description', None)
            if not description:
                description = "Event Reminder"

        else:  # we've inherited this reminder
            description = eim.Inherit
            trigger = eim.Inherit
            duration = eim.Inherit
            repeat = eim.Inherit

        yield model.DisplayAlarmRecord(
            item,
            description,
            trigger,
            duration,
            repeat,
        )
예제 #5
0
def str_uuid_for(item):
    eim_wrapped = eim.EIM(item)
    if not eim.EIM.installed_on(item):
        eim_wrapped.add()
    return str(eim_wrapped.uuid)