当前位置: 首页>>代码示例>>Python>>正文


Python ReservationBase.endDT方法代码示例

本文整理汇总了Python中MaKaC.rb_reservation.ReservationBase.endDT方法的典型用法代码示例。如果您正苦于以下问题:Python ReservationBase.endDT方法的具体用法?Python ReservationBase.endDT怎么用?Python ReservationBase.endDT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MaKaC.rb_reservation.ReservationBase的用法示例。


在下文中一共展示了ReservationBase.endDT方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _postprocess

# 需要导入模块: from MaKaC.rb_reservation import ReservationBase [as 别名]
# 或者: from MaKaC.rb_reservation.ReservationBase import endDT [as 别名]
    def _postprocess(self, obj, fossil, iface):

        if iface is IRoomMetadataWithReservationsFossil:
            (startDT, endDT) = (self._fromDT or MIN_DATETIME,
                                self._toDT or MAX_DATETIME)

            if self._fromDT or self._toDT:
                toDate = self._toDT.date() if self._toDT else None
                fromDate = self._fromDT.date() if self._fromDT else None

                resvEx = ReservationBase()
                resvEx.startDT = startDT
                resvEx.endDT = endDT
                resvEx.room = obj
                resvEx.isRejected = False
                resvEx.isCancelled = False

                if fromDate != toDate:
                    resvEx.repeatability = RepeatabilityEnum.daily

                resvs = set(c.withReservation for c in resvEx.getCollisions())
            else:
                resvs = obj.getReservations()

            iresvs1, iresvs2 = itertools.tee(itertools.ifilter(self._resvFilter, resvs), 2)
            fresvs = fossilize(iresvs1, IRoomReservationMetadataFossil, tz=self._tz, naiveTZ=self._serverTZ)

            for fresv, resv in itertools.izip(iter(fresvs), iresvs2):
                self._addOccurrences(fresv, resv, startDT, endDT)

            fossil['reservations'] = fresvs

        return fossil
开发者ID:VishrutMehta,项目名称:indico,代码行数:35,代码来源:http_api.py

示例2: _getAnswer

# 需要导入模块: from MaKaC.rb_reservation import ReservationBase [as 别名]
# 或者: from MaKaC.rb_reservation.ReservationBase import endDT [as 别名]
    def _getAnswer(self):
        p = ReservationBase()
        p.startDT = self._startDT
        p.endDT = self._endDT
        p.repeatability = self._repeatability

        rooms = CrossLocationQueries.getRooms(location=self._location, resvExample=p, available=True)

        return [room.id for room in rooms]
开发者ID:aninhalacerda,项目名称:indico,代码行数:11,代码来源:roomBooking.py

示例3: getMyAverageOccupation

# 需要导入模块: from MaKaC.rb_reservation import ReservationBase [as 别名]
# 或者: from MaKaC.rb_reservation.ReservationBase import endDT [as 别名]
    def getMyAverageOccupation( self, period="pastmonth" ):
        """
        FINAL (not intented to be overriden)
        Returns float <0, 1> representing how often - on the avarage -
        the room is booked during the working hours. (1 == all the time, 0 == never).
        """
        # Find collisions with last month period
        from MaKaC.rb_reservation import ReservationBase, RepeatabilityEnum
        resvEx = ReservationBase()
        now = datetime.now()
        if period == "pastmonth":
            resvEx.endDT = datetime( now.year, now.month, now.day, 17, 30 )
            resvEx.startDT = resvEx.endDT - timedelta( 30, 9 * 3600 ) # - 30 days and 9 hours
        elif period == "thisyear":
            resvEx.endDT = datetime( now.year, now.month, now.day, 17, 30 )
            resvEx.startDT = datetime( now.year, 1, 1, 0, 0 )
        resvEx.repeatability = RepeatabilityEnum.daily
        collisions = resvEx.getCollisions( rooms = [self] )

        totalWorkingDays = 0
        weekends = 0
        for day in iterdays( resvEx.startDT, resvEx.endDT ):
            if day.weekday() in [5,6]: # Skip Saturday and Sunday
                weekends += 1
                continue
            # if c.startDT is CERN Holiday: continue
            totalWorkingDays += 1

        booked = timedelta( 0 )
        for c in collisions:
            if c.startDT.weekday() in [5,6]: # Skip Saturday and Sunday
                continue
            # if c.startDT is CERN Holiday: continue
            booked = booked + ( c.endDT - c.startDT )
        totalBookableTime = totalWorkingDays * 9 # Hours
        bookedTime = booked.days * 24 + 1.0 * booked.seconds / 3600 # Hours
        if totalBookableTime > 0:
            return bookedTime / totalBookableTime
        else:
            return 0
开发者ID:vstitches,项目名称:indico,代码行数:42,代码来源:rb_room.py

示例4: getAverageOccupation

# 需要导入模块: from MaKaC.rb_reservation import ReservationBase [as 别名]
# 或者: from MaKaC.rb_reservation.ReservationBase import endDT [as 别名]
    def getAverageOccupation( **kwargs ):
        """
        FINAL (not intented to be overriden)
        Returns float <0, 1> representing how often - on the avarage -
        the rooms are booked during the working hours. (1 == all the time, 0 == never).
        """

        name = kwargs.get( 'location', Location.getDefaultLocation().friendlyName )

        # Get active, publically reservable rooms
        from MaKaC.rb_factory import Factory
        roomEx = Factory.newRoom()
        roomEx.isActive = True
        roomEx.isReservable = True

        rooms = CrossLocationQueries.getRooms( roomExample = roomEx, location = name )

        # Find collisions with last month period
        from MaKaC.rb_reservation import ReservationBase, RepeatabilityEnum
        resvEx = ReservationBase()
        now = datetime.now()
        resvEx.endDT = datetime( now.year, now.month, now.day, 17, 30 )
        resvEx.startDT = resvEx.endDT - timedelta( 30, 9 * 3600 ) # - 30 days and 9 hours
        resvEx.repeatability = RepeatabilityEnum.daily
        collisions = resvEx.getCollisions( rooms = rooms )

        totalWorkingDays = 0
        weekends = 0
        for day in iterdays( resvEx.startDT, resvEx.endDT ):
            if day.weekday() in [5,6]: # Skip Saturday and Sunday
                weekends += 1
                continue
            # if c.startDT is CERN Holiday: continue
            totalWorkingDays += 1

        booked = timedelta( 0 )
        for c in collisions:
            if c.startDT.weekday() in [5,6]: # Skip Saturday and Sunday
                continue
            # if c.startDT is CERN Holiday: continue
            booked = booked + ( c.endDT - c.startDT )
        totalBookableTime = totalWorkingDays * 9 * len( rooms ) # Hours
        bookedTime = booked.days * 24 + 1.0 * booked.seconds / 3600 # Hours
        if totalBookableTime > 0:
            return bookedTime / totalBookableTime
        else:
            return 0 # Error (no rooms in db)
开发者ID:vstitches,项目名称:indico,代码行数:49,代码来源:rb_room.py

示例5: reservation

# 需要导入模块: from MaKaC.rb_reservation import ReservationBase [as 别名]
# 或者: from MaKaC.rb_reservation.ReservationBase import endDT [as 别名]
    def reservation(self, locList):

        Factory.getDALManager().connect()

        resvEx = ReservationBase()
        resvEx.startDT = self._fromDT
        resvEx.endDT = self._toDT

        locList = filter(lambda loc: Location.parse(loc) is not None, locList)

        if self._fromDT or self._toDT:
            daysParam = (day.date() for day in rrule.rrule(rrule.DAILY, dtstart=self._fromDT, until=self._toDT))
        else:
            # slow!
            daysParam = None

        for loc in sorted(locList):
            resvs = CrossLocationQueries.getReservations(location=loc, resvExample=resvEx, days=daysParam)
            for obj in self._process(resvs, filter=self._resvFilter):
                yield obj

        Factory.getDALManager().disconnect()
开发者ID:VishrutMehta,项目名称:indico,代码行数:24,代码来源:http_api.py

示例6: getAverageOccupation

# 需要导入模块: from MaKaC.rb_reservation import ReservationBase [as 别名]
# 或者: from MaKaC.rb_reservation.ReservationBase import endDT [as 别名]
    def getAverageOccupation(**kwargs):
        """
        FINAL (not intented to be overriden)
        Returns float <0, 1> representing how often - on the avarage -
        the rooms are booked during the working hours. (1 == all the time, 0 == never).
        """

        name = kwargs.get("location", Location.getDefaultLocation().friendlyName)

        # Get active, publically reservable rooms
        from MaKaC.rb_factory import Factory

        roomEx = Factory.newRoom()
        roomEx.isActive = True
        roomEx.isReservable = True

        rooms = CrossLocationQueries.getRooms(roomExample=roomEx, location=name)

        # Find collisions with last month period
        from MaKaC.rb_reservation import ReservationBase, RepeatabilityEnum

        resvEx = ReservationBase()
        resvEx.endDT = datetime.combine(date.today(), time(17, 30))
        resvEx.startDT = resvEx.endDT.replace(hour=8) - timedelta(days=30)
        resvEx.repeatability = RepeatabilityEnum.daily
        collisions = resvEx.getCollisions(rooms=rooms)

        totalWorkingDays = sum(1 for day in iterdays(resvEx.startDT, resvEx.endDT) if day.weekday() not in (5, 6))
        booked = timedelta()
        for c in collisions:
            if c.startDT.weekday() in (5, 6):  # skip Saturday and Sunday
                continue
            booked += c.endDT - c.startDT
        totalBookableTime = totalWorkingDays * 9 * len(rooms)  # Hours
        bookedTime = (booked.days * 86400 + booked.seconds) / 3600.0
        if totalBookableTime > 0:
            return bookedTime / totalBookableTime
        else:
            return 0
开发者ID:arescope,项目名称:indico,代码行数:41,代码来源:rb_room.py

示例7: getMyAverageOccupation

# 需要导入模块: from MaKaC.rb_reservation import ReservationBase [as 别名]
# 或者: from MaKaC.rb_reservation.ReservationBase import endDT [as 别名]
    def getMyAverageOccupation(self, period="pastmonth"):
        """
        FINAL (not intented to be overriden)
        Returns float <0, 1> representing how often - on the avarage -
        the room is booked during the working hours. (1 == all the time, 0 == never).
        """
        # Find collisions with the givenmonth period
        from MaKaC.rb_reservation import ReservationBase, RepeatabilityEnum

        resvEx = ReservationBase()
        resvEx.endDT = datetime.combine(date.today(), time(17, 30))
        if period == "thisyear":
            resvEx.startDT = datetime(date.today().year, 1, 1, 8, 30)
        elif period == "pastmonth":
            resvEx.startDT = resvEx.endDT.replace(hour=8) - timedelta(days=30)
        elif period == "pastyear":
            resvEx.startDT = resvEx.endDT.replace(hour=8) - timedelta(days=365)
        else:
            raise ValueError("Invalid period: {0}".format(period))

        resvEx.repeatability = RepeatabilityEnum.daily
        collisions = resvEx.getCollisions(rooms=[self])

        totalWorkingDays = sum(1 for day in iterdays(resvEx.startDT, resvEx.endDT) if day.weekday() not in (5, 6))

        booked = timedelta()
        for c in collisions:
            if c.startDT.weekday() in (5, 6):  # skip Saturday and Sunday
                continue
            booked += c.endDT - c.startDT
        totalBookableTime = totalWorkingDays * 9  # Hours
        bookedTime = (booked.days * 86400 + booked.seconds) / 3600.0
        if totalBookableTime > 0:
            return bookedTime / totalBookableTime
        else:
            return 0
开发者ID:arescope,项目名称:indico,代码行数:38,代码来源:rb_room.py


注:本文中的MaKaC.rb_reservation.ReservationBase.endDT方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。