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


Python Conf.get_dict方法代码示例

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


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

示例1: test_get_dict

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import get_dict [as 别名]
    def test_get_dict(self):
        conf = Conf()
        self.assertEqual(conf.get_dict("s", "k"), {})

        conf.set("s", "k", "k1:v1;k2:v2;k3:v3")
        self.assertEqual(conf.get_dict("s", "k"), {"k1": "v1", "k2": "v2", "k3": "v3"})
开发者ID:rubenrua,项目名称:Galicaster,代码行数:8,代码来源:conf.py

示例2: TestFunctions

# 需要导入模块: from galicaster.core.conf import Conf [as 别名]
# 或者: from galicaster.core.conf.Conf import get_dict [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(self.conf.get_hour('s', 'k2', '11:11'), '11:11')


    def test_get_list(self):
        self.assertEqual(self.conf.get_list('s', 'k'), [])

        self.conf.set('s', 'k', '1 2 3 4 5 6')
        self.assertEqual(self.conf.get_list('s', 'k'), ['1', '2', '3', '4', '5', '6'])

        self.conf.set('s', 'k', 'one two three')
        self.assertEqual(self.conf.get_list('s', 'k'), ['one', 'two', 'three'])


    def test_get_choice(self):
        self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3'], '2'), '2')

        self.conf.set('s', 'k', '1')
        self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3']), '1')

        self.conf.set('s', 'k', 'TEST')
        self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3', 'test']), 'test')


    def test_get_choice_uppercase(self):
        self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3'], '2'), '2')

        self.conf.set('s', 'k', '1')
        self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3']), '1')

        self.conf.set('s', 'k', 'test')
        self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3', 'TEST']), 'TEST')


    def test_get_dict(self):
        self.assertEqual(self.conf.get_dict('s', 'k'), {})

        self.conf.set('s', 'k', 'k1:v1;k2:v2;k3:v3')
        self.assertEqual(self.conf.get_dict('s', 'k'), {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'})


    def test_get_json(self):
        self.assertEqual(self.conf.get_json('s', 'k'), {})

        self.conf.set('s', 'k', '{"a":{"a1":"value1", "a2":"value2"},"b": "value3"}')
        self.assertEqual(self.conf.get_json('s', 'k'), {"a": {"a1": "value1", "a2": "value2"}, "b": "value3"})


    def test_track_property(self):
        track = Track()
        track.name = 'name'
        self.assertEqual(track.name, 'name')
        self.assertEqual(track['name'], 'name')


    def test_get_hostname(self):
        conf = Conf(self.conf_file)
        conf.set('config', 'ingest', None)
        conf.set('basic', 'admin', 'True')
        conf.set('ingest', 'hostname', None)
        self.assertEqual('GCMobile-' + socket.gethostname(), conf.get_hostname())
        self.assertEqual(1, len(conf.get_tracks_in_oc_dict()))
        self.assertEqual({'capture.device.names': 'defaults'}, conf.get_tracks_in_oc_dict())
        conf.set('basic', 'admin', 'False')
        conf.set('ingest', 'hostname', None)
        self.assertEqual('GC-' + socket.gethostname(), conf.get_hostname())
        name = "123456_654321"
开发者ID:SussexLearningSystems,项目名称:Galicaster,代码行数:70,代码来源:conf.py


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