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


Python XmlConfigParser.load方法代码示例

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


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

示例1: setUp

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
    def setUp(self):
        BF3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.conf.loadFromString("""
                <configuration>
                </configuration>
            """)
        self.console = Bf3Parser(self.conf)

        from b3 import __file__ as b3_module__file__
        admin_config_file = os.path.normpath(os.path.join(os.path.dirname(b3_module__file__), "conf/plugin_admin.xml"))
        admin_config = XmlConfigParser()
        admin_config.load(admin_config_file)
        self.adminPlugin = AdminPlugin(self.console, admin_config)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()
        when(self.console).getPlugin('admin').thenReturn(self.adminPlugin)

        # monkeypatch the admin plugin
        self.console.patch_b3_admin_plugin()

        self.changeMap_patcher = patch.object(self.console, "changeMap")
        self.changeMap_mock = self.changeMap_patcher.start()

        self.player = FakeClient(self.console, name="Player1", guid="Player1GUID", groupBits=128)
        self.player.connects("p1")

        # GIVEN
        self.console.game.gameType = 'ConquestLarge0'
        when(self.console).write(('mapList.list', 0)).thenReturn(['4', '3', 'MP_001', 'RushLarge0', '1', 'MP_003',
                                                                  'ConquestSmall0', '2', 'XP5_001', 'ConquestSmall0',
                                                                  '2', 'MP_007', 'SquadDeathMatch0', '3'])
        when(self.console).write(('mapList.getMapIndices',)).thenReturn(['0', '0'])
开发者ID:Classixz,项目名称:big-brother-bot,代码行数:35,代码来源:test_bf3.py

示例2: Admin_functional_test

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
class Admin_functional_test(B3TestCase):
    """ tests from a class inherithing from Admin_functional_test must call self.init() """

    def setUp(self):
        B3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.p = AdminPlugin(self.console, self.conf)

    def init(self, config_content=None):
        """ optionally specify a config for the plugin. If called with no parameter, then the default config is loaded """
        if config_content is None:
            if not os.path.isfile(ADMIN_CONFIG_FILE):
                B3TestCase.tearDown(self)  # we are skipping the test at a late stage after setUp was called
                raise unittest.SkipTest("%s is not a file" % ADMIN_CONFIG_FILE)
            else:
                self.conf.load(ADMIN_CONFIG_FILE)
        else:
            self.conf.loadFromString(config_content)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="joeguid", groupBits=128, team=TEAM_RED)
        self.mike = FakeClient(
            self.console, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=TEAM_BLUE
        )
开发者ID:derfull,项目名称:big-brother-bot,代码行数:27,代码来源:test_admin_functional.py

示例3: Admin_TestCase

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
class Admin_TestCase(B3TestCase):

    def setUp(self):
        B3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.conf.load(ADMIN_CONFIG_FILE)
        self.p = AdminPlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
开发者ID:ozon,项目名称:big-brother-bot,代码行数:11,代码来源:test_admin.py

示例4: Admin_functional_test

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
class Admin_functional_test(B3TestCase):

    def setUp(self):
        B3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.conf.load(ADMIN_CONFIG_FILE)
        self.p = AdminPlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="joeguid", groupBits=128, team=TEAM_RED)
        self.mike = FakeClient(self.console, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=TEAM_BLUE)
开发者ID:ozon,项目名称:big-brother-bot,代码行数:14,代码来源:test_admin_functional.py

示例5: setUpModule

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
def setUpModule():
    global default_plugin_content, default_plugin_file, ADMIN_CONFIG, ADMIN_CONFIG_FILE, timer_patcher, feedparser_patcher
    if os.path.exists(default_plugin_file):
        with open(default_plugin_file, 'r') as f:
            default_plugin_content = f.read()

    ADMIN_CONFIG = XmlConfigParser()
    ADMIN_CONFIG.load(ADMIN_CONFIG_FILE)

    timer_patcher = patch('threading.Timer')
    timer_patcher.start()

    feedparser_patcher = patch.object(feedparser, 'parse')
    feedparser_patcher.start()
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:16,代码来源:test_adv.py

示例6: setUp

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
    def setUp(self):
        self.log = logging.getLogger('output')
        self.log.propagate = False

        B3TestCase.setUp(self)

        admin_conf = XmlConfigParser()
        admin_conf.load(ADMIN_CONFIG_FILE)
        self.adminPlugin = AdminPlugin(self.console, admin_conf)
        when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.console.gameName = "theGame"
        self.console.startup()
        self.log.propagate = True
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:18,代码来源:test_login.py

示例7: setUp

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
    def setUp(self):
        self.status_response = None # defaults to STATUS_RESPONSE module attribute
        self.conf = XmlConfigParser()
        self.conf.loadFromString("""<configuration></configuration>""")
        self.parser = RavagedParser(self.conf)
        self.parser.output = Mock()
        self.parser.output.write = Mock()

        ADMIN_CONFIG = XmlConfigParser()
        ADMIN_CONFIG.load(ADMIN_CONFIG_FILE)
        self.adminPlugin = AdminPlugin(self.parser, ADMIN_CONFIG)
        when(self.parser).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.parser.startup()
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:18,代码来源:test_ravaged.py

示例8: Admin_TestCase

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
class Admin_TestCase(B3TestCase):
    """ tests from a class inherithing from Admin_TestCase must call self.init() """
    def setUp(self):
        B3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.p = AdminPlugin(self.console, self.conf)

    def init(self, config_content=None):
        """ optionally specify a config for the plugin. If called with no parameter, then the default config is loaded """
        if config_content is None:
            if not os.path.isfile(ADMIN_CONFIG_FILE):
                B3TestCase.tearDown(self) # we are skipping the test at a late stage after setUp was called
                raise unittest.SkipTest("%s is not a file" % ADMIN_CONFIG_FILE)
            else:
                self.conf.load(ADMIN_CONFIG_FILE)
        else:
            self.conf.loadFromString(config_content)
        self.p.onLoadConfig()
        self.p.onStartup()
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:21,代码来源:test_admin.py

示例9: Test_Tk_default_config

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
class Test_Tk_default_config(B3TestCase):
    def setUp(self):
        super(Test_Tk_default_config, self).setUp()
        b3.console.gameName = "f00"
        self.conf = XmlConfigParser()
        self.conf.load(default_plugin_file)
        self.p = TkPlugin(b3.console, self.conf)
        self.p.onLoadConfig()

    def test(self):
        self.assertEqual("sfire", self.p._issue_warning)
        self.assertEqual(7, self.p._round_grace)
        self.assertEqual(40, self.p._maxLevel)
        self.assertEqual(400, self.p._maxPoints)
        self.assertEqual(
            {0: (2.0, 1.0, 2), 1: (2.0, 1.0, 2), 2: (1.0, 0.5, 1), 20: (1.0, 0.5, 0), 40: (0.75, 0.5, 0)},
            self.p._levels,
        )
        self.assertTrue(self.p._private_messages)
开发者ID:Kelso-Utah,项目名称:big-brother-bot,代码行数:21,代码来源:test_tk.py

示例10: LoginTestCase

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
class LoginTestCase(B3TestCase):
    """ Ease testcases that need an working B3 console and need to control the censor plugin config """

    def setUp(self):
        self.log = logging.getLogger('output')
        self.log.propagate = False

        B3TestCase.setUp(self)

        admin_conf = XmlConfigParser()
        admin_conf.load(ADMIN_CONFIG_FILE)
        self.adminPlugin = AdminPlugin(self.console, admin_conf)
        when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.console.gameName = "theGame"
        self.console.startup()
        self.log.propagate = True


    def tearDown(self):
        B3TestCase.tearDown(self)

    def init_plugin(self, config_content=None):
        self.conf = XmlConfigParser()
        if config_content:
            self.conf.setXml(config_content)
        else:
            self.conf.load(default_plugin_file)
        self.p = LoginPlugin(self.console, self.conf)

        self.log.setLevel(logging.DEBUG)
        self.log.info("============================= Login plugin: loading config ============================")
        self.p.onLoadConfig()
        self.log.info("============================= Login plugin: starting  =================================")
        self.p.onStartup()
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:39,代码来源:test_login.py

示例11: Test_Config

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
class Test_Config(B3TestCase):

    def setUp(self):
        self.log = logging.getLogger('output')
        self.log.propagate = False

        B3TestCase.setUp(self)
        self.console.startup()
        self.log.propagate = True
        self.log.setLevel(logging.DEBUG)

        self.conf = XmlConfigParser()
        self.p = ChatloggerPlugin(self.console, self.conf)

        when(self.console.config).get('b3', 'time_zone').thenReturn('GMT')
        when(b3).getB3Path().thenReturn("c:\\b3_folder")
        when(b3).getConfPath().thenReturn("c:\\b3_conf_folder")
        self.p.setup_fileLogger = Mock()


    def init(self, config_content=None):
        """ load plugin config and initialise the plugin """
        if config_content:
            self.conf.loadFromString(config_content)
        else:
            if os.path.isfile(CHATLOGGER_CONFIG_FILE):
                self.conf.load(CHATLOGGER_CONFIG_FILE)
            else:
                unittest.skip("default config file '%s' does not exists" % CHATLOGGER_CONFIG_FILE)
                return
        self.p.onLoadConfig()
        self.p.onStartup()


    def test_default_config(self):
        self.init()
        self.assertTrue(self.p._save2db)
        self.assertTrue(self.p._save2file)
        expected_log_file = 'c:\\b3_conf_folder\\chat.log' if sys.platform == 'win32' else 'c:\\b3_conf_folder/chat.log'
        self.assertEqual(expected_log_file, self.p._file_name)
        self.assertEqual("D", self.p._file_rotation_rate)
        self.assertEqual(0, self.p._max_age_in_days)
        self.assertEqual(0, self.p._max_age_cmd_in_days)
        self.assertEqual(0, self.p._hours)
        self.assertEqual(0, self.p._minutes)


    def test_empty_config(self):
        self.init("""<configuration plugin="chatlogger" />""")
        self.assertTrue(self.p._save2db)
        self.assertFalse(self.p._save2file)
        self.assertIsNone(self.p._file_name)
        self.assertIsNone(self.p._file_rotation_rate)
        self.assertEqual(0, self.p._max_age_in_days)
        self.assertEqual(0, self.p._max_age_cmd_in_days)
        self.assertEqual(0, self.p._hours)
        self.assertEqual(0, self.p._minutes)


    def test_conf1(self):
        self.init("""
            <configuration plugin="chatlogger">
                <settings name="purge">
                    <set name="max_age">7d</set>
                    <set name="hour">4</set>
                    <set name="min">0</set>
                </settings>
            </configuration>
        """)
        self.assertTrue(self.p._save2db)
        self.assertFalse(self.p._save2file)
        self.assertIsNone(self.p._file_name)
        self.assertIsNone(self.p._file_rotation_rate)
        self.assertEqual(7, self.p._max_age_in_days)
        self.assertEqual(0, self.p._max_age_cmd_in_days)
        self.assertEqual(4, self.p._hours)
        self.assertEqual(0, self.p._minutes)
开发者ID:82ndab-Bravo17,项目名称:b3-plugin-chatlogger,代码行数:79,代码来源:test_config.py

示例12: XmlConfigParser

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import load [as 别名]
            self._maps_parsed = True
            self.info('There was at least one error opening your map files many/few %s/%s' % (self._maps_load_error['many'], self._maps_load_error['few']))
################################################################################################################
#
# Debuging, Testing
#
################################################################################################################


if __name__ == '__main__':
    from b3.config import XmlConfigParser
    from b3.fake import fakeConsole
    from b3.fake import joe, simon, moderator, superadmin, reg, admin
    import time
    config = XmlConfigParser() 
    config.load('conf/plugin_autofillbf3.xml.test')
    event_start = type('lamdbaobject', (object,), {'type' :  b3.events.EVT_GAME_ROUND_START})()
    event_end = type('lamdbaobject', (object,), {'type' :  b3.events.EVT_GAME_ROUND_END})()
    event_join = type('lamdbaobject', (object,), {'type' :  b3.events.EVT_CLIENT_JOIN})()
    event_leave = type('lamdbaobject', (object,), {'type' :  b3.events.EVT_CLIENT_DISCONNECT})()
    p = Autofillbf3Plugin(fakeConsole, config)
    p.console.setCvar('maxPlayers', 18)
    p.onStartup()
    p.onLoadConfig()
    """  Adjust slot size
    
    p.onEvent(event_start)
    joe.connects(cid = 1)
    p.onEvent(event_join)
    simon.connects(cid = 2)
    p.onEvent(event_join)
开发者ID:sebwert,项目名称:b3-plugin-autofillbf3,代码行数:33,代码来源:autofillbf3.py


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