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


Python View.days_str方法代码示例

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


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

示例1: convertDate

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import days_str [as 别名]
 def convertDate(self, dictionary):
     view = View()
     if "day" in dictionary.keys(): 
         dictionary["day"] = view.days_str(dictionary["day"])
     if "startTime" in dictionary.keys():
         dictionary["startTime"] = view.time_str(dictionary["startTime"])
     if "endTime" in dictionary.keys():
         dictionary["endTime"] = view.time_str(dictionary["endTime"])
开发者ID:xil12008,项目名称:paxos,代码行数:10,代码来源:consumer.py

示例2: Producer

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import days_str [as 别名]

#.........这里部分代码省略.........
                    self.savequeue()
                    print "Roger that. Your command queue:"
                    self.printqueue()
            elif cmds[0]=="del":
                if len(cmds)!=2:
                    warning = "format: del <calendar name>"
                    print warning
                    continue 
                else:
                    if not self.dataPass(cmds):
                        print "Wrong Input"
                        continue
                    self.queue.put({"operation":"del", "app_name":cmds[1]})
                    self.savequeue()
                    print "Roger that. Your command queue:"
                    self.printqueue()
            elif cmds[0]=="viewlocal":
                if len(cmds)!=1:
                    warning = "format: viewlocal"
                    print warning
                    continue
                else:
                    print "Roger that. Your local commited log:"
                    self.showCalendar()
                    print "Your calendar:"
                    print self.constructCalendar().keys()
            elif cmds[0]=="view":
                if len(cmds)!=1:
                    warning = "format: view"
                    print warning
                    continue
                else:
                    self.queue.put({"operation":"view"})
                    self.savequeue()
                    print "Roger that. Your command queue:"
                    self.printqueue()
            elif cmds[0]=="log":
                if len(cmds)!=1:
                    warning = "format: log"
                    print warning
                    continue
                else:
                    print "Roger that. Your local log:"
                    self.showCalendar(committed = False)
            elif cmds[0]=="queue":
                if len(cmds)!=1:
                    warning = "format: queue"
                    print warning
                    continue
                else:
                    print "Roger that. Your command FIFO queue:"
                    self.printqueue()
            else:
                print "Unknown command. Only accept add/del/view/log"
            print "-" * 32 
            time.sleep(1)

    def showCalendar(self, record = None, committed = True):
        if not record: record = self.readlog()
        try:
            print "<" * 25
            for entryID in range(10000): 
                if entryID in record.keys():
                    if committed:
                        if "commitVal" in record[entryID].keys():
                            self.convertDate(record[entryID]["commitVal"])
                            print entryID, " | ",
                            print record[entryID]["commitVal"].values()
                    else:
                        print entryID, ":", 
                        print record[entryID]
            print ">" * 25
        except:
            print "Empty"

    def convertDate(self, dictionary):
        if "day" in dictionary.keys(): 
            dictionary["day"] = self.view.days_str(dictionary["day"])
        if "startTime" in dictionary.keys():
            dictionary["startTime"] = self.view.time_str(dictionary["startTime"])
        if "endTime" in dictionary.keys():
            dictionary["endTime"] = self.view.time_str(dictionary["endTime"])

    def savequeue(self):
        f = open('user.queue', 'w')
        f.write(str(list(self.queue.queue)))

    def printqueue(self):
        print str(list(self.queue.queue))
    
    def readqueue(self):
        queue = Queue.Queue()
        try:
            f = open('user.queue', 'r')
            for line in f:
                queue.queue = deque(eval(line))
        except:
            ""
        finally:
            return queue
开发者ID:xil12008,项目名称:paxos,代码行数:104,代码来源:producer.py


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