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


Python OrdDict.update方法代码示例

本文整理汇总了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
开发者ID:JGunning,项目名称:OpenAOL-TV,代码行数:104,代码来源:data_mythtv.py


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