Пример #1
0
    def iterateObjectsInDays(self, sDate=None, eDate=None):

        sDay = int(datetimeToUnixTime(datetime(sDate.year, sDate.month, sDate.day))) if sDate else None
        eDay = int(datetimeToUnixTime(datetime(eDate.year, eDate.month, eDate.day))) if eDate else None
        for day in self._idxDay.itervalues(sDay, eDay):
            for event in day:
                yield event
Пример #2
0
    def iterateObjectsInDays(self, sDate=None, eDate=None):

        sDay = int(datetimeToUnixTime(datetime(sDate.year, sDate.month, sDate.day))) if sDate else None
        eDay = int(datetimeToUnixTime(datetime(eDate.year, eDate.month, eDate.day))) if eDate else None
        for day in self._idxDay.itervalues(sDay, eDay):
            for event in day:
                yield event
Пример #3
0
 def getObjectsEndingInDay(self, date):
     day = datetime(date.year, date.month, date.day, tzinfo=date.tzinfo)
     if self._idxDay.has_key(int(datetimeToUnixTime(day))):
         return set([
             event for event in self._idxDay[int(datetimeToUnixTime(day))]
             if event.getEndDate() < day + timedelta(1)
         ])
     else:
         return set()
Пример #4
0
 def getObjectsEndingAfter( self, date ):
     day = datetime(date.year, date.month, date.day)
     nextDay = day + timedelta(1)
     res = set()
     if self._idxDay.has_key(int(datetimeToUnixTime(day))):
         res = set([event for event in self._idxDay[int(datetimeToUnixTime(day))] if event.getEndDate() >= date])
     for day in self._idxDay.values(int(datetimeToUnixTime(nextDay))):
         res.update(set(day))
     return res
Пример #5
0
 def getObjectsEndingAfter( self, date ):
     day = datetime(date.year, date.month, date.day)
     nextDay = day + timedelta(1)
     res = set()
     if self._idxDay.has_key(int(datetimeToUnixTime(day))):
         res = set([event for event in self._idxDay[int(datetimeToUnixTime(day))] if event.getEndDate() >= date])
     for day in self._idxDay.values(int(datetimeToUnixTime(nextDay))):
         res.update(set(day))
     return res
Пример #6
0
 def getObjectsStartingInDay(self, date):
     day = datetime(date.year, date.month, date.day, tzinfo=date.tzinfo)
     if self._idxDay.has_key(int(datetimeToUnixTime(day))):
         return set([
             event for event in self._idxDay[int(datetimeToUnixTime(day))]
             if event.getStartDate() >= day
         ])
     else:
         return set()
Пример #7
0
 def getObjectsInDays( self, sDate=None, eDate=None ):
     sDay = int(datetimeToUnixTime(datetime(sDate.year, sDate.month, sDate.day))) if sDate else None
     eDay = int(datetimeToUnixTime(datetime(eDate.year, eDate.month, eDate.day))) if eDate else None
     res = set()
     #checking if 2038 problem occurs
     if sDay > BTREE_MAX_INT or eDay > BTREE_MAX_INT:
         return res
     for event in self._idxDay.values(sDay, eDay):
         res.update(event)
     return res
Пример #8
0
    def iterateObjectsInDays(self, sDate=None, eDate=None):
        """
        Returns all the events between two dates WITHOUT taking into account the starting and ending times.
        """

        sDay = int(datetimeToUnixTime(datetime(sDate.year, sDate.month, sDate.day))) if sDate else None
        eDay = int(datetimeToUnixTime(datetime(eDate.year, eDate.month, eDate.day))) if eDate else None
        for day in self._idxDay.itervalues(sDay, eDay):
            for event in day:
                yield event
Пример #9
0
    def iterateObjectsInDays(self, sDate=None, eDate=None):
        """
        Returns all the events between two dates WITHOUT taking into account the starting and ending times.
        """

        sDay = int(datetimeToUnixTime(datetime(sDate.year, sDate.month, sDate.day))) if sDate else None
        eDay = int(datetimeToUnixTime(datetime(eDate.year, eDate.month, eDate.day))) if eDate else None
        for day in self._idxDay.itervalues(sDay, eDay):
            for event in day:
                yield event
Пример #10
0
 def getObjectsEndingInDay(self, date):
     day = datetime(date.year, date.month, date.day, tzinfo=date.tzinfo)
     if self._idxDay.has_key(int(datetimeToUnixTime(day))):
         return set(
             [
                 event
                 for event in self._idxDay[int(datetimeToUnixTime(day))]
                 if event.getEndDate() < day + timedelta(1)
             ]
         )
     else:
         return set()
Пример #11
0
 def getObjectsStartingAfter( self, date ):
     stDay = datetime(date.year, date.month, date.day)
     nextDay = stDay + timedelta(1)
     previousDay = stDay - timedelta(1)
     res = set()
     if self._idxDay.has_key(int(datetimeToUnixTime(stDay))):
         res = set([event for event in self._idxDay[int(datetimeToUnixTime(stDay))] if event.getStartDate() >= date])
     for day in self._idxDay.values(int(datetimeToUnixTime(nextDay))):
         res.update(set(day))
     for day in self._idxDay.values(max = int(datetimeToUnixTime(previousDay))):
         res.difference_update(set(day))
     res.difference_update(set([event for event in self._idxDay[int(datetimeToUnixTime(stDay))] if event.getStartDate() < date]))
     return res
Пример #12
0
 def getObjectsInDays(self, sDate=None, eDate=None):
     sDay = int(
         datetimeToUnixTime(datetime(sDate.year, sDate.month,
                                     sDate.day))) if sDate else None
     eDay = int(
         datetimeToUnixTime(datetime(eDate.year, eDate.month,
                                     eDate.day))) if eDate else None
     res = set()
     #checking if 2038 problem occurs
     if sDay > BTREE_MAX_INT or eDay > BTREE_MAX_INT:
         return res
     for event in self._idxDay.values(sDay, eDay):
         res.update(event)
     return res
Пример #13
0
 def getObjectsStartingAfter( self, date ):
     stDay = datetime(date.year, date.month, date.day)
     nextDay = stDay + timedelta(1)
     previousDay = stDay - timedelta(1)
     res = set()
     if self._idxDay.has_key(int(datetimeToUnixTime(stDay))):
         res = set([event for event in self._idxDay[int(datetimeToUnixTime(stDay))] if event.getStartDate() >= date])
     for day in self._idxDay.values(int(datetimeToUnixTime(nextDay))):
         res.update(set(day))
     for day in self._idxDay.values(max=int(datetimeToUnixTime(previousDay))):
         res.difference_update(set(day))
     res.difference_update(set([event for event in
                           self._idxDay.get(int(datetimeToUnixTime(stDay)), []) if event.getStartDate() < date]))
     return res
Пример #14
0
 def hasObjectsAfter(self, date):
     stDay = datetime(date.year, date.month, date.day)
     if self._idxDay:
         lastDay = self._idxDay.keys()[-1]
         return lastDay > int(datetimeToUnixTime(stDay))
     else:
         # Empty index? Then there's nothing after for sure
         return False
Пример #15
0
 def hasObjectsAfter(self, date):
     stDay = datetime(date.year, date.month, date.day)
     if self._idxDay:
         lastDay = self._idxDay.keys()[-1]
         return lastDay > int(datetimeToUnixTime(stDay))
     else:
         # Empty index? Then there's nothing after for sure
         return False
Пример #16
0
    def getObjectsIn(self, sDate, eDate):
        """
        TODO: Reimplement using iterateObjectsIn!!
        (or get rid of this one, as the other should be faster)
        """

        sDay = datetime(sDate.year, sDate.month, sDate.day)
        eDay = datetime(eDate.year, eDate.month, eDate.day)
        res = set()
        if sDay == eDay:
            if self._idxDay.has_key(int(datetimeToUnixTime(sDay))):
                res = set(
                    [
                        event
                        for event in self._idxDay[int(datetimeToUnixTime(sDay))]
                        if event.getStartDate() <= eDate and event.getEndDate() >= sDate
                    ]
                )
        elif sDay < eDay:
            res = set()
            if self._idxDay.has_key(int(datetimeToUnixTime(sDay))):
                res = set(
                    [event for event in self._idxDay[int(datetimeToUnixTime(sDay))] if event.getEndDate() >= sDate]
                )
            if self._idxDay.has_key(int(datetimeToUnixTime(eDay))):
                res.update(
                    [event for event in self._idxDay[int(datetimeToUnixTime(eDay))] if event.getStartDate() <= eDate]
                )
            res.update(self.getObjectsInDays(sDay + timedelta(1), eDay - timedelta(1)))
        return res
Пример #17
0
 def getObjectsEndingIn(self, sDate, eDate):
     sDay = datetime(sDate.year, sDate.month, sDate.day, tzinfo=sDate.tzinfo)
     eDay = datetime(eDate.year, eDate.month, eDate.day, tzinfo=eDate.tzinfo)
     res = set()
     if sDay == eDay:
         if self._idxDay.has_key(int(datetimeToUnixTime(sDay))):
             res = set(
                 [
                     event
                     for event in self._idxDay[int(datetimeToUnixTime(sDay))]
                     if event.getEndDate() <= eDate and event.getEndDate() >= sDate
                 ]
             )
     elif sDay < eDay:
         res = set()
         if self._idxDay.has_key(int(datetimeToUnixTime(sDay))):
             res = set(
                 [
                     event
                     for event in self._idxDay[int(datetimeToUnixTime(sDay))]
                     if event.getEndDate() >= sDate and event.getEndDate() < sDay + timedelta(1)
                 ]
             )
         if self._idxDay.has_key(int(datetimeToUnixTime(eDay))):
             res.update(
                 [event for event in self._idxDay[int(datetimeToUnixTime(eDay))] if event.getEndDate() <= eDate]
             )
         for day in range((eDay - sDay).days - 1):
             res.update(self.getObjectsEndingInDay(sDay + timedelta(1 + day)))
     return res
Пример #18
0
    def iterateObjectsIn(self, sDate, eDate):
        """
        Returns all the events between two dates taking into account the starting and ending times.
        """
        sDay = datetime(sDate.year, sDate.month, sDate.day) if sDate else None
        eDay = datetime(eDate.year, eDate.month, eDate.day) if eDate else None

        if sDay and sDay == eDay:
            if int(datetimeToUnixTime(sDay)) in self._idxDay:
                for event in self._idxDay[int(datetimeToUnixTime(sDay))]:
                    if event.getStartDate() <= eDate and event.getEndDate() >= sDate:
                        yield event
            return

        if sDay and int(datetimeToUnixTime(sDay)) in self._idxDay:
            for event in self._idxDay[int(datetimeToUnixTime(sDay))]:
                if event.getEndDate() >= sDate:
                    yield event

        if sDay and eDay:
            fromTS, toTS = sDay + timedelta(1), eDay - timedelta(1)
        elif sDay:
            fromTS, toTS = sDay + timedelta(), None
        elif eDay:
            fromTS, toTS = None, eDay - timedelta(1)
        else:
            fromTS, toTS = None, None

        for evt in self.iterateObjectsInDays(fromTS, toTS):
            yield evt

        if eDay and int(datetimeToUnixTime(eDay)) in self._idxDay:
            for event in self._idxDay[int(datetimeToUnixTime(eDay))]:
                if event.getStartDate() <= eDate:
                    yield event
Пример #19
0
    def iterateObjectsIn(self, sDate, eDate):
        sDay = datetime(sDate.year, sDate.month, sDate.day) if sDate else None
        eDay = datetime(eDate.year, eDate.month, eDate.day) if eDate else None

        if sDay and sDay == eDay:
            if int(datetimeToUnixTime(sDay)) in self._idxDay:
                for event in self._idxDay[int(datetimeToUnixTime(sDay))]:
                    if event.getStartDate() <= eDate and event.getEndDate(
                    ) >= sDate:
                        yield event
            return

        # keep track of the records that have been already sent

        if sDay and int(datetimeToUnixTime(sDay)) in self._idxDay:
            for event in self._idxDay[int(datetimeToUnixTime(sDay))]:
                if event.getEndDate() >= sDate:
                    yield event

        if sDay and eDay:
            fromTS, toTS = sDay + timedelta(1), eDay - timedelta(1)
        elif sDay:
            fromTS, toTS = sDay + timedelta(), None
        elif eDay:
            fromTS, toTS = None, eDay - timedelta(1)
        else:
            fromTS, toTS = None, None

        for evt in self.iterateObjectsInDays(fromTS, toTS):
            yield evt

        if eDay and int(datetimeToUnixTime(eDay)) in self._idxDay:
            for event in self._idxDay[int(datetimeToUnixTime(eDay))]:
                if event.getStartDate() <= eDate:
                    yield event
Пример #20
0
    def getObjectsIn(self, sDate, eDate):
        """
        TODO: Reimplement using iterateObjectsIn!!
        (or get rid of this one, as the other should be faster)
        """

        sDay = datetime(sDate.year, sDate.month, sDate.day)
        eDay = datetime(eDate.year, eDate.month, eDate.day)
        res = set()
        if sDay == eDay:
            if self._idxDay.has_key(int(datetimeToUnixTime(sDay))):
                res = set([
                    event
                    for event in self._idxDay[int(datetimeToUnixTime(sDay))]
                    if event.getStartDate() <= eDate
                    and event.getEndDate() >= sDate
                ])
        elif sDay < eDay:
            res = set()
            if self._idxDay.has_key(int(datetimeToUnixTime(sDay))):
                res = set([
                    event
                    for event in self._idxDay[int(datetimeToUnixTime(sDay))]
                    if event.getEndDate() >= sDate
                ])
            if self._idxDay.has_key(int(datetimeToUnixTime(eDay))):
                res.update([
                    event
                    for event in self._idxDay[int(datetimeToUnixTime(eDay))]
                    if event.getStartDate() <= eDate
                ])
            res.update(
                self.getObjectsInDays(sDay + timedelta(1),
                                      eDay - timedelta(1)))
        return res
Пример #21
0
    def iterateObjectsIn(self, sDate, eDate):
        """
        Returns all the events between two dates taking into account the starting and ending times.
        """
        sDay = datetime(sDate.year, sDate.month, sDate.day) if sDate else None
        eDay = datetime(eDate.year, eDate.month, eDate.day) if eDate else None

        if sDay and sDay == eDay:
            if int(datetimeToUnixTime(sDay)) in self._idxDay:
                for event in self._idxDay[int(datetimeToUnixTime(sDay))]:
                    if event.getStartDate() <= eDate and event.getEndDate() >= sDate:
                        yield event
            return

        if sDay and int(datetimeToUnixTime(sDay)) in self._idxDay:
            for event in self._idxDay[int(datetimeToUnixTime(sDay))]:
                if event.getEndDate() >= sDate:
                    yield event

        if sDay and eDay:
            fromTS, toTS = sDay + timedelta(1), eDay - timedelta(1)
        elif sDay:
            fromTS, toTS = sDay + timedelta(), None
        elif eDay:
            fromTS, toTS = None, eDay - timedelta(1)
        else:
            fromTS, toTS = None, None

        for evt in self.iterateObjectsInDays(fromTS, toTS):
            yield evt

        if eDay and int(datetimeToUnixTime(eDay)) in self._idxDay:
            for event in self._idxDay[int(datetimeToUnixTime(eDay))]:
                if event.getStartDate() <= eDate:
                    yield event
Пример #22
0
    def iterateObjectsIn(self, sDate, eDate):
        sDay = datetime(sDate.year, sDate.month, sDate.day) if sDate else None
        eDay = datetime(eDate.year, eDate.month, eDate.day) if eDate else None

        if sDay and sDay == eDay:
            if int(datetimeToUnixTime(sDay)) in self._idxDay:
                for event in self._idxDay[int(datetimeToUnixTime(sDay))]:
                    if event.getStartDate() <= eDate and event.getEndDate() >= sDate:
                        yield event
            return

        # keep track of the records that have been already sent

        if sDay and int(datetimeToUnixTime(sDay)) in self._idxDay:
            for event in self._idxDay[int(datetimeToUnixTime(sDay))]:
                if event.getEndDate() >= sDate:
                    yield event

        if sDay and eDay:
            fromTS, toTS = sDay + timedelta(1), eDay - timedelta(1)
        elif sDay:
            fromTS, toTS = sDay + timedelta(), None
        elif eDay:
            fromTS, toTS = None, eDay - timedelta(1)
        else:
            fromTS, toTS = None, None

        for evt in self.iterateObjectsInDays(fromTS, toTS):
            yield evt

        if eDay and int(datetimeToUnixTime(eDay)) in self._idxDay:
            for event in self._idxDay[int(datetimeToUnixTime(eDay))]:
                if event.getStartDate() <= eDate:
                    yield event
Пример #23
0
 def indexConf(self, conf):
     # Note: conf can be any object which has getEndDate() and getStartDate() methods
     self._idxDay._p_changed = True
     days = (conf.getEndDate().date() - conf.getStartDate().date()).days
     startDate = datetime(conf.getStartDate().year, conf.getStartDate().month, conf.getStartDate().day)
     for day in range(days + 1):
         key = int(datetimeToUnixTime(startDate + timedelta(day)))
         #checking if 2038 problem occurs
         if key > BTREE_MAX_INT:
             continue
         if self._idxDay.has_key(key):
             self._idxDay[key].add(conf)
         else:
             self._idxDay[key] = OOSet([conf])
Пример #24
0
def getRequestURL(action, arguments = {}):

    actionURL = getActionURL(action)

    indicoID = getEVOOptionValueByName("indicoUserID")
    indicoPassword = getEVOOptionValueByName("indicoPassword")
    expirationTime = int(datetimeToUnixTime(nowutc() + timedelta(minutes = getEVOOptionValueByName('expirationTime'))) * 1000)

    arguments["from"] = createLoginKey(indicoID, indicoPassword, expirationTime)

    url = URL(actionURL)
    url.setParams(arguments)

    return url
Пример #25
0
 def indexConf(self, conf):
     # Note: conf can be any object which has getEndDate() and getStartDate() methods
     self._idxDay._p_changed = True
     days = (conf.getEndDate().date() - conf.getStartDate().date()).days
     startDate = datetime(conf.getStartDate().year, conf.getStartDate().month, conf.getStartDate().day)
     for day in range(days + 1):
         key = int(datetimeToUnixTime(startDate + timedelta(day)))
         #checking if 2038 problem occurs
         if key > BTREE_MAX_INT:
             continue
         if self._idxDay.has_key(key):
             self._idxDay[key].add(conf)
         else:
             self._idxDay[key] = OOSet([conf])
Пример #26
0
def getRequestURL(action, arguments = {}):
    
    actionURL = getActionURL(action)
    
    indicoID = getEVOOptionValueByName("indicoUserID")
    indicoPassword = getEVOOptionValueByName("indicoPassword")
    expirationTime = int(datetimeToUnixTime(nowutc() + timedelta(minutes = getEVOOptionValueByName('expirationTime'))) * 1000)
    
    arguments["from"] = createLoginKey(indicoID, indicoPassword, expirationTime)
    
    url = URL(actionURL)
    url.setParams(arguments)
    url.setSeparator('&')
    
    return url
Пример #27
0
 def unindexConf( self, conf):
     # Note: conf can be any object which has getEndDate() and getStartDate() methods
     self._idxDay._p_changed = True
     days = (conf.getEndDate().date() - conf.getStartDate().date()).days
     startDate = datetime(conf.getStartDate().year, conf.getStartDate().month, conf.getStartDate().day)
     for dayNumber in range(days + 1):
         day = int(datetimeToUnixTime(startDate + timedelta(dayNumber)))
         #checking if 2038 problem occurs
         if day > BTREE_MAX_INT:
             continue
         if self._idxDay.has_key( day ):
             if conf in self._idxDay[day]:
                 self._idxDay[day].remove(conf)
             if len(self._idxDay[day]) == 0:
                 del self._idxDay[day]
Пример #28
0
 def unindexConf( self, conf):
     # Note: conf can be any object which has getEndDate() and getStartDate() methods
     self._idxDay._p_changed = True
     days = (conf.getEndDate().date() - conf.getStartDate().date()).days
     startDate = datetime(conf.getStartDate().year, conf.getStartDate().month, conf.getStartDate().day)
     for dayNumber in range(days + 1):
         day = int(datetimeToUnixTime(startDate + timedelta(dayNumber)))
         #checking if 2038 problem occurs
         if day > BTREE_MAX_INT:
             continue
         if self._idxDay.has_key( day ):
             if conf in self._idxDay[day]:
                 self._idxDay[day].remove(conf)
             if len(self._idxDay[day]) == 0:
                 del self._idxDay[day]
Пример #29
0
 def getObjectsStartingIn( self, sDate, eDate):
     sDay = datetime(sDate.year, sDate.month, sDate.day, tzinfo = sDate.tzinfo)
     eDay = datetime(eDate.year, eDate.month, eDate.day, tzinfo = eDate.tzinfo)
     res = set()
     if sDay == eDay:
         if self._idxDay.has_key(int(datetimeToUnixTime(sDay))):
             res = set([event for event in self._idxDay[int(datetimeToUnixTime(sDay))] if event.getStartDate() <= eDate and event.getStartDate() >= sDate])
     elif sDay < eDay:
         if self._idxDay.has_key(int(datetimeToUnixTime(sDay))):
             res = set([event for event in self._idxDay[int(datetimeToUnixTime(sDay))] if event.getStartDate() >= sDate])
         if self._idxDay.has_key(int(datetimeToUnixTime(eDay))):
             res.update([event for event in self._idxDay[int(datetimeToUnixTime(eDay))] if event.getStartDate() <= eDate and event.getStartDate() >= eDay ])
         for day in range((eDay - sDay).days - 1):
             res.update(self.getObjectsStartingInDay( sDay + timedelta(1 + day)))
     return res
Пример #30
0
 def getObjectsInDay(self, date):
     day = datetime(date.year, date.month, date.day)
     if self._idxDay.has_key(int(datetimeToUnixTime(day))):
         return set(self._idxDay[int(datetimeToUnixTime(day))])
     else:
         return set()
Пример #31
0
 def hasObjectsAfter(self, date):
     stDay = datetime(date.year, date.month, date.day)
     lastDay = self._idxDay.keys()[-1]
     return lastDay > int(datetimeToUnixTime(stDay))
Пример #32
0
 def getObjectsInDay( self, date ):
     day = datetime(date.year, date.month, date.day)
     if self._idxDay.has_key(int(datetimeToUnixTime(day))):
         return set(self._idxDay[int(datetimeToUnixTime(day))])
     else:
         return set()
Пример #33
0
 def getObjectsStartingInDay( self, date ):
     day = datetime(date.year, date.month, date.day, tzinfo = date.tzinfo)
     if self._idxDay.has_key(int(datetimeToUnixTime(day))):
         return set([event for event in self._idxDay[int(datetimeToUnixTime(day))] if event.getStartDate() >= day])
     else:
         return set()