Пример #1
0
 def getFilter(self):
     # This is where we can filter out things we don't want to send to
     # Cosmo
     filter = super(CosmoConduit, self).getFilter()
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     return filter
Пример #2
0
 def getFilter(self):
     # This is where we can filter out things we don't want to send to
     # Cosmo
     filter = super(CosmoConduit, self).getFilter()
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     filter += eim.lookupSchemaURI('cid:[email protected]')
     return filter
Пример #3
0
def exportFile(rv,
               path,
               collection,
               activity=None,
               translatorClass=translator.SharingTranslator,
               serializerClass=ics.ICSSerializer,
               filters=None,
               debug=False):

    if filters is None:
        filter = lambda rs: rs
    else:
        filter = eim.Filter(None, u'Temporary filter')
        for uri in filters:
            filter += eim.lookupSchemaURI(uri)
        filter = filter.sync_filter

    trans = translatorClass(rv)
    trans.startImport()

    total = len(collection)
    if activity:
        activity.update(totalWork=total)

    outbound = {}
    for item in collection:
        if (isinstance(item, pim.Note)
                and pim.EventStamp(item).isTriageOnlyModification()):
            continue  # skip triage-only modifications

        alias = trans.getAliasForItem(item)
        outbound[alias] = filter(eim.RecordSet(trans.exportItem(item)))
        if activity:
            activity.update(work=1, msg=_(u"Exporting items..."))

    text = serializerClass.serialize(rv,
                                     outbound,
                                     name=collection.displayName,
                                     monolithic=True)

    output = open(path, "wb")
    output.write(text)
    output.close()

    if activity:
        activity.update(totalWork=None, msg=_(u"Exporting complete."))
Пример #4
0
def exportFile(rv, path, collection, activity=None,
    translatorClass=translator.SharingTranslator,
    serializerClass=ics.ICSSerializer,
    filters=None, debug=False):

    if filters is None:
        filter = lambda rs: rs
    else:
        filter = eim.Filter(None, u'Temporary filter')
        for uri in filters:
            filter += eim.lookupSchemaURI(uri)
        filter = filter.sync_filter

    trans = translatorClass(rv)
    trans.startImport()

    total = len(collection)
    if activity:
        activity.update(totalWork=total)

    outbound = { }
    for item in collection:
        if (isinstance(item, pim.Note) and
            pim.EventStamp(item).isTriageOnlyModification()):
            continue # skip triage-only modifications
        
        alias = trans.getAliasForItem(item)
        outbound[alias] = filter(eim.RecordSet(trans.exportItem(item)))
        if activity:
            activity.update(work=1, msg=_(u"Exporting items..."))

    text = serializerClass.serialize(rv, outbound, name=collection.displayName,
                                     monolithic=True)

    output = open(path, "wb")
    output.write(text)
    output.close()

    if activity:
        activity.update(totalWork=None, msg=_(u"Exporting complete."))
Пример #5
0
def importFile(rv, path, collection=None, activity=None,
    translatorClass=translator.SharingTranslator,
    serializerClass=ics.ICSSerializer,
    filters=None, debug=False):

    input = open(path, "r")
    text = input.read()
    input.close()
    
    with rv.reindexingDeferred():

        if filters is None:
            filter = lambda rs: rs
        else:
            filter = eim.Filter(None, u'Temporary filter')
            for uri in filters:
                filter += eim.lookupSchemaURI(uri)
            filter = filter.sync_filter
    
        trans = translatorClass(rv)
    
        if activity:
            activity.update(msg=_(u"Parsing file..."), totalWork=None)
        inbound, extra = serializerClass.deserialize(rv, text)
    
        total = len(inbound)
        if activity:
            activity.update(totalWork=total)
    
        trans.startImport()
        for alias, rs in inbound.items():
            trans.importRecords(filter(rs))
            if activity:
                activity.update(work=1, msg=_(u"Importing items..."))

        showTZDialog = getattr(trans, 'timezonePromptRequested', False)

        trans.finishImport()
    
        
    
        if collection is None:
            name = extra.get('name', _(u"Untitled"))
            collection = pim.SmartCollection(itsView=rv, displayName=name)
    
        for alias in inbound:
            uuid = trans.getUUIDForAlias(alias)
            if uuid:
                item = rv.findUUID(uuid)
                if item is not None:
                    collection.add(item)
                    pim.setTriageStatus(item, 'auto')
                    item_to_change = getattr(item, 'inheritFrom', item)
                    item_to_change.read = True
    
        if activity:
            activity.update(totalWork=None, msg=_(u"Importing complete."))
    
    if showTZDialog:
        import wx
        app = wx.GetApp()
        if app is not None:
            import application.dialogs.TurnOnTimezones as TurnOnTimezones
            TurnOnTimezones.ShowTurnOnTimezonesDialog(view=rv)
    
    return collection
Пример #6
0
def importFile(rv,
               path,
               collection=None,
               activity=None,
               translatorClass=translator.SharingTranslator,
               serializerClass=ics.ICSSerializer,
               filters=None,
               debug=False):

    input = open(path, "r")
    text = input.read()
    input.close()

    with rv.reindexingDeferred():

        if filters is None:
            filter = lambda rs: rs
        else:
            filter = eim.Filter(None, u'Temporary filter')
            for uri in filters:
                filter += eim.lookupSchemaURI(uri)
            filter = filter.sync_filter

        trans = translatorClass(rv)

        if activity:
            activity.update(msg=_(u"Parsing file..."), totalWork=None)
        inbound, extra = serializerClass.deserialize(rv, text)

        total = len(inbound)
        if activity:
            activity.update(totalWork=total)

        trans.startImport()
        for alias, rs in inbound.items():
            trans.importRecords(filter(rs))
            if activity:
                activity.update(work=1, msg=_(u"Importing items..."))

        showTZDialog = getattr(trans, 'timezonePromptRequested', False)

        trans.finishImport()

        if collection is None:
            name = extra.get('name', _(u"Untitled"))
            collection = pim.SmartCollection(itsView=rv, displayName=name)

        for alias in inbound:
            uuid = trans.getUUIDForAlias(alias)
            if uuid:
                item = rv.findUUID(uuid)
                if item is not None:
                    collection.add(item)
                    pim.setTriageStatus(item, 'auto')
                    item_to_change = getattr(item, 'inheritFrom', item)
                    item_to_change.read = True

        if activity:
            activity.update(totalWork=None, msg=_(u"Importing complete."))

    if showTZDialog:
        import wx
        app = wx.GetApp()
        if app is not None:
            import application.dialogs.TurnOnTimezones as TurnOnTimezones
            TurnOnTimezones.ShowTurnOnTimezonesDialog(view=rv)

    return collection
Пример #7
0
def getFilter(filterUris):
    filter = eim.Filter(None, u'Temporary filter')
    for uri in filterUris:
        filter += eim.lookupSchemaURI(uri)
    return filter
Пример #8
0
 def getTranslator(self):
     # This is so when we need multiple translator types, we'll still only
     # have one place to call to get them...
     return eim.lookupSchemaURI("cid:[email protected]")(self.itsView)
Пример #9
0
def getFilter(filterUris):
    filter = eim.Filter(None, u'Temporary filter')
    for uri in filterUris:
        filter += eim.lookupSchemaURI(uri)
    return filter
Пример #10
0
 def getTranslator(self):
     # This is so when we need multiple translator types, we'll still only
     # have one place to call to get them...
     return eim.lookupSchemaURI("cid:[email protected]")(self.itsView)