本文整理汇总了Python中orddict.OrdDict.count方法的典型用法代码示例。如果您正苦于以下问题:Python OrdDict.count方法的具体用法?Python OrdDict.count怎么用?Python OrdDict.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orddict.OrdDict
的用法示例。
在下文中一共展示了OrdDict.count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProcessPrograms
# 需要导入模块: from orddict import OrdDict [as 别名]
# 或者: from orddict.OrdDict import count [as 别名]
def ProcessPrograms(self):
rdata = OrdDict()
edata = OrdDict()
ldata = OrdDict()
udata = OrdDict()
data = {'scheduled': rdata,
'expireable': edata,
'livetv': ldata,
'upcoming': udata}
progs = list(MythTV.Recorded.getAllEntries())
upcoming = list(_BE.getUpcomingRecordings())
livetv = [prog for prog in progs if prog.recgroup == 'LiveTV']
recs = [prog for prog in progs if prog.recgroup != 'LiveTV']
expireable = [prog for prog in recs if prog.autoexpire]
times = []
for dataset in (recs, expireable, livetv, upcoming):
if len(dataset):
try:
deltas = [rec.endtime-rec.starttime for rec in dataset]
except:
deltas = [rec.recendts-rec.recstartts for rec in dataset]
secs = self.td_to_secs(deltas.pop())
for delta in deltas:
secs += self.td_to_secs(delta)
times.append(secs)
else:
times.append(0)
rdata.count = len(recs)
rdata.size = sum([rec.filesize for rec in recs])
rdata.time = times[0]
edata.count = len(expireable)
edata.size = sum([rec.filesize for rec in expireable])
edata.time = times[1]
ldata.count = len(livetv)
ldata.size = sum([rec.filesize for rec in livetv])
ldata.time = times[2]
udata.count = len(upcoming)
udata.time = times[3]
return {'recordings': data}
示例2: ProcessScheduler
# 需要导入模块: from orddict import OrdDict [as 别名]
# 或者: from orddict.OrdDict import count [as 别名]
def ProcessScheduler(self):
def stddev(data):
avg = sum(data) / len(data)
return avg, (sum([(d - avg) ** 2 for d in data]) / len(data)) ** 0.5
data = OrdDict()
data.count = 0
data.match_avg = 0
data.match_stddev = 0
data.place_avg = 0
data.place_stddev = 0
r = re.compile("Scheduled ([0-9]*) items in [0-9.]* = ([0-9.]*) match \+ ([0-9.]*) place")
data = OrdDict()
c = _DB.cursor()
c.execute(
"""SELECT details FROM mythlog
WHERE module='scheduler'
AND message='Scheduled items'"""
)
runs = [r.match(d[0]).groups() for d in c.fetchall()]
if len(runs) == 0:
return {"scheduler": data}
a, s = stddev([float(r[2]) for r in runs])
for i, r in reversed(list(enumerate(runs))):
if abs(float(r[2]) - a) > (3 * s):
runs.pop(i)
data = OrdDict()
count = [float(r[0]) for r in runs]
match = [float(r[1]) for r in runs]
place = [float(r[2]) for r in runs]
data.count = int(sum(count) / len(count))
data.match_avg, data.match_stddev = stddev(match)
data.place_avg, data.place_stddev = stddev(place)
return {"scheduler": data}