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


Python Scheduler.clearD方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Scheduler import Scheduler [as 别名]
# 或者: from Scheduler.Scheduler import clearD [as 别名]

#.........这里部分代码省略.........
                    times = "all"

                if type(weekdays) != list:
                    weekdays = [weekdays]
                
                weekdayAsNum = []
                for d in weekdays:
                    weekdayAsNum.append(self.weekdayAbbr[day.lower()])

                if self.scheduler.clearW(weekdayAsNum, times, lunch) == 1:
                    print("Successfully cleared shifts %s on %s."%(times, weekdays))
                else:
                    print("Shifts not cleared.")

            elif command == "clear day" or command == "clr d":
                days = self.getInputOfType("Clear a shift for which day(s)? : ", "int", range(1, self.scheduler.numDays+1))
                if days == "cancel": continue
                print("")
                lunch = self.getLunch()
                if lunch == "cancel": continue
                print("")
                allShifts = self.getInputOfType("Would you like to clear all shifts? (y/n) :", "bool")
                if allShifts == "cancel": continue
                print("")
                if not allShifts:
                    times = self.getTimes()
                    if times == "cancel": continue
                else:
                    times = "all"

                if type(days) != list:
                    days = [days]

                if self.scheduler.clearD(days, times, lunch) == 1:
                    print("Successfully cleared shifts %s on %s."%(times, days))
                else:
                    print("Shifts not cleared.")

            else:
                self.cmdNotRecognized(command)

    def getLunch(self):
        while True:
            lunch = self.getInputOfType("Is this a lunch or dinner shift? : ", "str", [5,6])
            if lunch == "lunch":
                return True
                
            elif lunch == "dinner":
                return False

            elif lunch == "cancel":
                return "cancel"
                
            else:
                print("Please enter either 'lunch' or 'dinner'.")

    def getTimes(self):
        print("You will now be prompted to enter times at which each shift will begin, you can enter as many as you like. " +
                    "\nTo stop entering times, enter 'stop' or 's'.")
        times = []
        tmp = self.getInputOfType("Enter a time : ", "time") #get first input
        if tmp == "cancel": return tmp #propagate "cancel" out to be handled later

        while tmp != "skip":
            times.append(tmp)
            tmp = self.getInputOfType("Enter a time : ", "time", None, True)
开发者ID:calebawatts,项目名称:Shift-Scheduler,代码行数:70,代码来源:UI.py


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