本文整理汇总了Python中orddict.OrdDict.update方法的典型用法代码示例。如果您正苦于以下问题:Python OrdDict.update方法的具体用法?Python OrdDict.update怎么用?Python OrdDict.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orddict.OrdDict
的用法示例。
在下文中一共展示了OrdDict.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from orddict import OrdDict [as 别名]
# 或者: from orddict.OrdDict import update [as 别名]
#.........这里部分代码省略.........
data['vtpertuner'] = sum(virtual)/float(virtual[0])
return data
def ProcessSmoltInfo(self):
smoltfile=home+"/.mythtv/smolt.info"
config = {}
try:
config_file= open(smoltfile)
for line in config_file:
line = line.strip()
if line and line[0] is not "#" and line[-1] is not "=":
var,val = line.rsplit("=",1)
config[var.strip()] = val.strip("\"")
except:
pass
try:
myth_systemrole = config["systemtype" ]
except:
myth_systemrole = '0'
try:
mythremote = config["remote" ]
except:
mythremote = 'unknown'
return myth_systemrole , mythremote
def ProcessLogUrgency(self):
c = _DB.cursor()
c.execute("""SELECT level,count(level) FROM logging GROUP BY level""")
levels = ('EMERG', 'ALERT', 'CRIT', 'ERR',
'WARNING', 'NOTICE', 'INFO') # ignore debugging from totals
counts = {}
total = 0.
for level,count in c.fetchall():
if level in range(len(levels)):
counts[levels[level]] = count
total += count
for k,v in counts.items():
counts[k] = v/total
return {'logurgency':counts}
def get_data(self,gate):
self._data = OrdDict()
for func in (self.ProcessVersion,
self.ProcessPrograms,
self.ProcessHistorical,
self.ProcessSource,
self.ProcessTimeZone,
self.ProcessStorage,
self.ProcessAudio,
self.ProcessVideoProfile,
self.ProcessMySQL,
self.ProcessScheduler,
self.Processtuners,
self.ProcessLogUrgency):
try:
self._data.update(func())
except:
pass
self._data.theme = _SETTINGS.Theme
self._data.country = _SETTINGS.Country
self._data.channel_count = len([c for c in MythTV.Channel.getAllEntries() if c.visible])
self._data.language = _SETTINGS.Language.lower()
self._data.mythtype, self._data.remote = self.ProcessSmoltInfo()
if _DB.settings.NULL.SystemUUID is None:
_DB.settings.NULL.SystemUUID = UuidDb().gen_uuid()
self._data.uuid = _DB.settings.NULL.SystemUUID
def serialize(self):
res = self._data
return res
def _dump_rst_section(self, lines, title, data, line_break=True):
lines.append(title)
for k,v in sorted(data.items()):
lines.append('- %s:\n %s \n' %(k,v))
if line_break:
lines.append('')
def dump_rst(self, lines):
serialized = self.serialize()
lines.append('MythTV Features')
lines.append('-----------------------------')
self._dump_rst_section(lines, '', serialized)
def _dump(self):
lines = []
self.dump_rst(lines)
print '\n'.join(lines)
print