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


Python XmlConfigParser.setXml方法代码示例

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


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

示例1: testAdmins

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def testAdmins():
     conf = XmlConfigParser()
     conf.setXml("""
   <configuration plugin="adv">
     <settings name="settings">
         <set name="rate">1s</set>
     </settings>
     <ads>
         <ad>^2Do you like B3? Consider donating to the project at www.BigBrotherBot.net</ad>
         <ad>@admins</ad>
     </ads>
 </configuration>
     """)
     p = AdvPlugin(fakeConsole, conf)
     p.onStartup()
     
     p.adv()
     print "-----------------------------"
     time.sleep(4)
     joe.connects(1)
     time.sleep(4)
     moderator.connects(2)
     time.sleep(4)
     superadmin.connects(3)
     
     time.sleep(60)
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:28,代码来源:adv.py

示例2: CensorurtTestCase

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
class CensorurtTestCase(B3TestCase):
    """
    Ease testcases that need an working B3 console and need to control the censorurt plugin config
    """
    def setUp(self):
        # Timer needs to be patched or the Censor plugin would schedule a 2nd check one minute after
        # penalizing a player.
        self.timer_patcher = patch('threading.Timer')
        self.timer_patcher.start()

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

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

        self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="zaerezarezar", groupBits=1, team=b3.TEAM_UNKNOWN)

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

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

    def init_plugin(self, config_content):
        self.conf.setXml(config_content)
        self.log.setLevel(logging.DEBUG)
        self.log.info("============================= Censor plugin: loading config ============================")
        self.p.onLoadConfig()
        self.log.info("============================= Censor plugin: starting  =================================")
        self.p.onStartup()
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:35,代码来源:__init__.py

示例3: SpamcontrolTestCase

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

    def setUp(self):
        self.timer_patcher = patch('threading.Timer')
        self.timer_patcher.start()

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

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

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

    def init_plugin(self, config_content):
        self.conf = XmlConfigParser()
        self.conf.setXml(config_content)
        self.p = SpamcontrolPlugin(self.console, self.conf)

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

示例4: test_nominal

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_nominal(self):
     conf = XmlConfigParser()
     conf.setXml("""
     <configuration plugin="teamspeakbf">
     	<settings name="teamspeakServer">
             <set name="host">foo_host</set>
             <set name="queryport">foo_queryport</set>
             <set name="id">1</set>
             <set name="login">foo_login</set>
             <set name="password">foo_password</set>
         </settings>
         <settings name="teamspeakChannels">
             <set name="B3">channel name</set>
             <set name="team1">Team 1 name</set>
             <set name="team2">Team 2 name</set>
             <set name="DefaultTarget">team</set>
         </settings>
     </configuration>
     """)
     p = TeamspeakbfPlugin(fakeConsole, conf)
     p.readConfig()
     self.assertEqual('channel name', p.TS3ChannelB3)
     self.assertEqual('Team 1 name', p.TS3ChannelTeam1)
     self.assertEqual('Team 2 name', p.TS3ChannelTeam2)
     self.assertEqual('team', p.autoswitchDefaultTarget)
开发者ID:82ndab-Bravo17,项目名称:b3-plugin-teamspeakbf,代码行数:27,代码来源:test_config.py

示例5: CensorTestCase

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
class CensorTestCase(B3TestCase):
    """base class for TestCase to apply to the Censor plugin"""

    def setUp(self):
        # Timer needs to be patched or the Censor plugin would schedule a 2nd check one minute after
        # penalizing a player.
        self.timer_patcher = patch('threading.Timer')
        self.timer_patcher.start()

        super(CensorTestCase, self).setUp()
        self.conf = XmlConfigParser()
        self.conf.setXml(r"""
            <configuration plugin="censor">
                <badwords>
                    <penalty type="warning" reasonkeyword="racist"/>
                </badwords>
                <badnames>
                    <penalty type="warning" reasonkeyword="badname"/>
                </badnames>
            </configuration>
        """)
        self.p = CensorPlugin(self.console, self.conf)
        self.p.onLoadConfig()

    def tearDown(self):
        self.timer_patcher.stop()

    def assert_name_penalized_count(self, name, count):
        self.p.penalizeClientBadname = Mock()

        mock_client = Mock()
        mock_client.connected = True
        mock_client.exactName = name

        self.p.checkBadName(mock_client)
        self.assertEquals(count, self.p.penalizeClientBadname.call_count, "name '%s' should have been penalized %s time" % (name, count))

    def assert_name_is_penalized(self, name):
        self.assert_name_penalized_count(name, 1)

    def assert_name_is_not_penalized(self, name):
        self.assert_name_penalized_count(name, 0)

    def assert_chat_is_penalized(self, text):
        self.p.penalizeClient = Mock()

        mock_client = Mock()
        mock_client.connected = True

        try:
            self.p.checkBadWord(text, mock_client)
            self.fail("text [%s] should have raised a VetoEvent" % text)
        except b3.events.VetoEvent, e:
            self.assertEquals(1, self.p.penalizeClient.call_count, "text [%s] should have been penalized" % text)
            return self.p.penalizeClient.call_args[0] if len(self.p.penalizeClient.call_args) else None
开发者ID:ozon,项目名称:big-brother-bot,代码行数:57,代码来源:test_censor.py

示例6: test_no_client_table

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_no_client_table(self, pluginCronTab_mock):
     conf = XmlConfigParser()
     conf.setXml(
         r"""<configuration plugin="status">
         <settings name="settings">
             <set name="interval">60</set>
             <set name="output_file">~/status.xml</set>
         </settings>
     </configuration>"""
     )
     self.p = StatusPlugin(self.console, conf)
     self.p.onLoadConfig()
     self.assertEqual("current_clients", self.p._clientTable)
开发者ID:carriercomm,项目名称:big-brother-bot,代码行数:15,代码来源:test_status.py

示例7: test_restart_with_delay

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_restart_with_delay():
     conf = XmlConfigParser()
     conf.setXml(
         """
     <configuration>
         <restart name="at restart + 7s" delay="7s">
             <rcon>say "we just restarted 7s ago"</rcon>
         </restart>
     </configuration>
     """
     )
     fakeConsole.gameName = "urt41"
     p3 = SchedulerPlugin(fakeConsole, conf)
     p3.onLoadConfig()
     p3.onStartup()
开发者ID:thomasleveil,项目名称:b3-plugin-scheduler,代码行数:17,代码来源:scheduler.py

示例8: test_classic_syntax

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_classic_syntax():
     conf = XmlConfigParser()
     conf.setXml(
         """
     <configuration plugin="scheduler">
         <cron name="test0" seconds="0">
             <rcon>say "hello you"</rcon>
             <rcon>say "hello world"</rcon>
         </cron>
     </configuration>
     """
     )
     fakeConsole.gameName = "urt41"
     p = SchedulerPlugin(fakeConsole, conf)
     p.onLoadConfig()
     p.onStartup()
开发者ID:thomasleveil,项目名称:b3-plugin-scheduler,代码行数:18,代码来源:scheduler.py

示例9: CommandTestCase

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
class CommandTestCase(B3TestCase):
    def setUp(self):
        B3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.conf.setXml("""
            <configuration plugin="admin">
                <settings name="warn">
                    <set name="warn_delay">5</set>
                </settings>
            </configuration>
        """)
        self.p = AdminPlugin(b3.console, self.conf)
        self.mock_client = Mock(spec=Client, name="client")
        self.mock_client.maxLevel = 0
        self.mock_client.exactName = "MockClient"
        self.mock_command = Mock(spec=Command, name='cmd')
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:18,代码来源:test_admin.py

示例10: test_hourly

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_hourly():
     conf = XmlConfigParser()
     conf.setXml(
         """
     <configuration>
         <hourly name="hourly1" minutes="13">
             <rcon>say "^9Nightime maprotation in effect."</rcon>
             <rcon>set sv_maprotation "gametype ctf map mp_carentan gametype ctf map mp_toujane gametype ctf map mp_buhlert gametype ctf map mp_railyard gametype ctf map mp_sfrance_final gametype ctf map mp_leningrad gametype ctf map mp_farmhouse gametype ctf map mp_decoy gametype ctf map mp_carentan gametype ctf map mp_dawnville gametype ctf map mp_matmata gametype ctf map mp_breakout gametype ctf map mp_burgundy"</rcon>
         </hourly>
     </configuration>
     """
     )
     fakeConsole.gameName = "urt41"
     p3 = SchedulerPlugin(fakeConsole, conf)
     p3.onLoadConfig()
     p3.onStartup()
开发者ID:thomasleveil,项目名称:b3-plugin-scheduler,代码行数:18,代码来源:scheduler.py

示例11: init_plugin

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
    def init_plugin(self, config_content=None):
        conf = None
        if config_content:
            conf = XmlConfigParser()
            conf.setXml(config_content)
        elif os.path.exists(default_plugin_file):
            conf = default_plugin_file
        else:
            unittest.skip("cannot get default plugin config file at %s" % default_plugin_file)

        self.p = AdvPlugin(self.console, conf)
        self.conf = self.p.config
        self.log.setLevel(logging.DEBUG)
        self.log.info("============================= Adv plugin: loading config ============================")
        self.p.onLoadConfig()
        self.log.info("============================= Adv plugin: starting  =================================")
        self.p.onStartup()
开发者ID:tanka8,项目名称:big-brother-bot,代码行数:19,代码来源:test_adv.py

示例12: test_default_values

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_default_values(self):
     conf = XmlConfigParser()
     conf.setXml("""
     <configuration plugin="teamspeakbf">
     	<settings name="teamspeakServer">
             <set name="host">foo_host</set>
             <set name="queryport">foo_queryport</set>
             <set name="id">1</set>
             <set name="login">foo_login</set>
             <set name="password">foo_password</set>
         </settings>
     </configuration>
     """)
     p = TeamspeakPlugin(fakeConsole, conf)
     p.readConfig()
     self.assertEqual(TeamspeakPlugin.TS3ChannelB3, p.TS3ChannelB3)
     self.assertEqual(TeamspeakPlugin.TS3ChannelTeam1, p.TS3ChannelTeam1)
     self.assertEqual(TeamspeakPlugin.TS3ChannelTeam2, p.TS3ChannelTeam2)
开发者ID:thomasleveil,项目名称:b3-plugin-teamspeak,代码行数:20,代码来源:test_config.py

示例13: test_bf3

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_bf3():
     conf = XmlConfigParser()
     conf.setXml(
         """
     <configuration plugin="scheduler">
         <cron name="every3m" minutes="*/3">
             <frostbite command="yell">
                 <arg>my text</arg>
                 <arg>10</arg>
                 <arg>all</arg>
             </frostbite>
         </cron>
     </configuration>
     """
     )
     fakeConsole.gameName = "bf3"
     p2 = SchedulerPlugin(fakeConsole, conf)
     p2.onLoadConfig()
     p2.onStartup()
开发者ID:thomasleveil,项目名称:b3-plugin-scheduler,代码行数:21,代码来源:scheduler.py

示例14: test_frostbite_syntax

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_frostbite_syntax():
     conf = XmlConfigParser()
     conf.setXml(
         """
     <configuration plugin="scheduler">
         <cron name="test2" seconds="10,30">
             <frostbite command="admin.say">
                 <arg>server shuting down</arg>
                 <arg>all</arg>
             </frostbite>
             <frostbite command="admin.shutDown" />
         </cron>
     </configuration>
     """
     )
     fakeConsole.gameName = "moh"
     p2 = SchedulerPlugin(fakeConsole, conf)
     p2.onLoadConfig()
     p2.onStartup()
开发者ID:thomasleveil,项目名称:b3-plugin-scheduler,代码行数:21,代码来源:scheduler.py

示例15: test_DefaultTarget_off

# 需要导入模块: from b3.config import XmlConfigParser [as 别名]
# 或者: from b3.config.XmlConfigParser import setXml [as 别名]
 def test_DefaultTarget_off(self):
     conf = XmlConfigParser()
     conf.setXml("""
     <configuration plugin="teamspeakbf">
     	<settings name="teamspeakServer">
             <set name="host">foo_host</set>
             <set name="queryport">foo_queryport</set>
             <set name="id">1</set>
             <set name="login">foo_login</set>
             <set name="password">foo_password</set>
         </settings>
         <settings name="teamspeakChannels">
             <set name="DefaultTarget">off</set>
         </settings>
     </configuration>
     """)
     p = TeamspeakbfPlugin(fakeConsole, conf)
     p.readConfig()
     self.assertEqual('off', p.autoswitchDefaultTarget)
开发者ID:82ndab-Bravo17,项目名称:b3-plugin-teamspeakbf,代码行数:21,代码来源:test_config.py


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