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


Python DataManager.getByRange方法代码示例

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


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

示例1: countTasks

# 需要导入模块: from DataManager import DataManager [as 别名]
# 或者: from DataManager.DataManager import getByRange [as 别名]
 def countTasks(self):
     """Count tasks statistics divided by projects"""
     self._data = DataManager.getByRange(self._fromDate, self._toDate)
     res = {}
     for date, task, projectName in self._data:
         if task == "__start__":
             self.timings.setPrevDate(None)
         
         spentSeconds = self.timings.count(date, Tasks.taskType(task))
         
         if Tasks.taskType(task) != "work":
             continue
             
         if spentSeconds:
             if projectName not in res:
                 res[projectName] = {}
                 
             if task not in res[projectName]:
                 res[projectName][task] = spentSeconds
             else:
                 res[projectName][task] += spentSeconds
     self._countAttrib([v for k in res for v in res[k].values()])
     if res:
         ret = {}
         for k in res.keys():
             ret[k] = sorted(res[k].iteritems(), key=lambda item:item[1], reverse=True)
         return ret
     else:
         return {}
开发者ID:DMaiorino,项目名称:MacTimeLog,代码行数:31,代码来源:Statistics.py

示例2: _countObject

# 需要导入模块: from DataManager import DataManager [as 别名]
# 或者: from DataManager.DataManager import getByRange [as 别名]
    def _countObject(self, objType, targetAction):
        """Generic function for calculating projects data or slacking statistics"""
        self._data = DataManager.getByRange(self._fromDate, self._toDate)
        res = {}

        for date, task, projectName in self._data:
            if task == "__start__":
                self.timings.setPrevDate(None)
            objKey = projectName if objType == "project" else task
            
            spentSeconds = self.timings.count(date, Tasks.taskType(task))

            if Tasks.taskType(task) != targetAction:
                self.timings.setPrevDate(date)
                continue

            if spentSeconds:
                if objKey not in res:
                    res[objKey] = spentSeconds
                else:
                    res[objKey] += spentSeconds
                    
        self._countAttrib(res.values())
        if res:
            return sorted(res.iteritems(), key=lambda item:item[1], reverse=True)
        else:
            return []
开发者ID:DMaiorino,项目名称:MacTimeLog,代码行数:29,代码来源:Statistics.py


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