本文整理汇总了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 {}
示例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 []