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


Python YamlConfigurationFile.get_section方法代码示例

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


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

示例1: test_with_file_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_file_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            files:
                aiml:
                    file: $BOT_ROOT/aiml/test.aiml
                    errors: /tmp/y-bot-errors.txt
                    duplicates: /tmp/y-bot-duplicates.txt
                    conversation: /tmp/y-bot-conversation.txt
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        files_config = yaml.get_section("files", brain_config)
        self.assertIsNotNone(files_config)

        aiml_config = BrainAIMLFileConfiguration()
        aiml_config.load_config_section(yaml, files_config, ".")

        self.assertEqual("./aiml/test.aiml", aiml_config.file)
        self.assertEqual("aiml", aiml_config.extension)
        self.assertFalse(aiml_config.directories)
        self.assertEqual("/tmp/y-bot-errors.txt", aiml_config.errors.filename)
        self.assertEqual("/tmp/y-bot-duplicates.txt", aiml_config.duplicates.filename)
        self.assertEqual("/tmp/y-bot-conversation.txt", aiml_config.conversation.filename)
开发者ID:Freiza,项目名称:program-y,代码行数:29,代码来源:test_aimlfile.py

示例2: test_with_new_format_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_new_format_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            files:
                aiml:
                    errors:
                      file: /tmp/y-bot_errors.csv
                      format: csv
                      encoding: utf-8
                      delete_on_start: true
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        files_config = yaml.get_section("files", brain_config)
        self.assertIsNotNone(files_config)
        aiml_config = yaml.get_section("aiml", files_config)
        self.assertIsNotNone(aiml_config)

        debugfile_config = DebugFileConfiguration("errors")
        debugfile_config.load_config_section(yaml, aiml_config, ".")

        self.assertEquals("/tmp/y-bot_errors.csv", debugfile_config.filename)
        self.assertEquals("csv", debugfile_config.file_format)
        self.assertEquals("utf-8", debugfile_config.encoding)
        self.assertTrue(debugfile_config.delete_on_start)
开发者ID:Freiza,项目名称:program-y,代码行数:30,代码来源:test_debugfile.py

示例3: test_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        bot:
            conversations:
              max_histories: 666
              initial_topic: topic1
              restore_last_topic: true
              type: file
              config_name: file_storage
        
            file_storage:
              dir: $BOT_ROOT/conversations
        """, ConsoleConfiguration(), ".")

        bot_config = yaml.get_section("bot")

        convo_config = BotConversationsConfiguration()
        convo_config.load_config_section(yaml, bot_config, ".")

        self.assertEquals(convo_config.section_name, "conversations")

        self.assertEquals(666, convo_config.max_histories)
        self.assertEquals("topic1", convo_config.initial_topic)
        self.assertTrue(convo_config.restore_last_topic)

        self.assertEquals(convo_config.type, "file")
        self.assertIsNotNone(convo_config.storage)
开发者ID:Freiza,项目名称:program-y,代码行数:31,代码来源:test_conversations.py

示例4: test_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            services:
                REST:
                    classname: programy.services.rest.GenericRESTService
                    method: GET
                    host: 0.0.0.0
                Pannous:
                    classname: programy.services.pannous.PannousService
                    url: http://weannie.pannous.com/api
                Pandora:
                    classname: programy.services.pandora.PandoraService
                    url: http://www.pandorabots.com/pandora/talk-xml
                Wikipedia:
                    classname: programy.services.wikipediaservice.WikipediaService
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        services_config = BrainServicesConfiguration()
        services_config.load_config_section(yaml, brain_config, ".")

        self.assertTrue(services_config.exists("REST"))
        self.assertTrue(services_config.exists("Pannous"))
        self.assertTrue(services_config.exists("Pandora"))
        self.assertTrue(services_config.exists("Wikipedia"))
        self.assertFalse(services_config.exists("Other"))
开发者ID:Freiza,项目名称:program-y,代码行数:32,代码来源:test_services.py

示例5: test_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
          bot:  bot
          prompt: ">>>"
          license_keys: $BOT_ROOT/config/license.keys
          bot_selector: programy.clients.client.DefaultBotSelector
          renderer: programy.clients.render.text.TextRenderer
          scheduler:
            name: Scheduler1
            debug_level: 0
            add_listeners: True
            remove_all_jobs: True
        """, ConsoleConfiguration(), ".")

        bot_config = yaml.get_section("console")

        client_config = ClientConfigurationData("test")
        client_config.load_configuration(yaml, bot_config, ".")

        self.assertEquals("./config/license.keys", client_config.license_keys)

        self.assertEquals("programy.clients.client.DefaultBotSelector", client_config.bot_selector)

        self.assertIsNotNone(client_config.scheduler)
        self.assertEquals("Scheduler1", client_config.scheduler.name)
        self.assertEquals(0, client_config.scheduler.debug_level)
        self.assertTrue(client_config.scheduler.add_listeners)
        self.assertTrue(client_config.scheduler.remove_all_jobs)

        self.assertEquals("programy.clients.render.text.TextRenderer", client_config.renderer)
开发者ID:Freiza,项目名称:program-y,代码行数:35,代码来源:test_config.py

示例6: test_load_from_configuration_no_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_load_from_configuration_no_data(self):
        collection = DynamicsCollection()
        self.assertIsNotNone(collection)

        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            dynamic:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        dynamics_config = BrainDynamicsConfiguration()
        dynamics_config.load_config_section(yaml, brain_config, ".")

        collection.load_from_configuration(dynamics_config)

        self.assertIsNotNone(collection.dynamic_sets)
        self.assertTrue(collection.is_dynamic_set("NUMBER"))

        self.assertIsNotNone(collection.dynamic_maps)
        self.assertTrue(collection.is_dynamic_map("PLURAL"))
        self.assertTrue(collection.is_dynamic_map("SINGULAR"))
        self.assertTrue(collection.is_dynamic_map("PREDECESSOR"))
        self.assertTrue(collection.is_dynamic_map("SUCCESSOR"))

        self.assertIsNotNone(collection.dynamic_vars)
开发者ID:Freiza,项目名称:program-y,代码行数:30,代码来源:test_dynamics.py

示例7: test_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
          scheduler:
            name: Scheduler1
            debug_level: 0
            add_listeners: True
            remove_all_jobs: True
            
            jobstore:
                name:   mongo
                
                mongo:
                    collection: example_jobs
    
                redis:
                    jobs_key: example.jobs
                    run_times_key: example.run_times
    
                sqlalchemy:
                    url: sqlite:///jobs.sqlite
    
            threadpool:
                max_workers: 20
        
            processpool:
                max_workers: 5   
        
            job_defaults:
                coalesce: False
                max_instances: 3
          
        """, ConsoleConfiguration(), ".")

        bot_config = yaml.get_section("console")

        scheduler_config = SchedulerConfiguration()
        scheduler_config.load_config_section(yaml, bot_config, ".")

        self.assertEquals("Scheduler1", scheduler_config.name)
        self.assertEquals(0, scheduler_config.debug_level)
        self.assertTrue(scheduler_config.add_listeners)
        self.assertTrue(scheduler_config.remove_all_jobs)

        self.assertIsNotNone(scheduler_config.jobstore)
        self.assertIsNotNone(scheduler_config.jobstore.jobstore)
        self.assertEquals("example_jobs", scheduler_config.jobstore.jobstore.collection)

        self.assertIsNotNone(scheduler_config.threadpool)
        self.assertEquals(20, scheduler_config.threadpool.max_workers)

        self.assertIsNotNone(scheduler_config.processpool)
        self.assertEquals(5, scheduler_config.processpool.max_workers)

        self.assertIsNotNone(scheduler_config.job_defaults)
        self.assertEquals(False, scheduler_config.job_defaults.coalesce)
        self.assertEquals(3, scheduler_config.job_defaults.max_instances)
开发者ID:Freiza,项目名称:program-y,代码行数:61,代码来源:test_scheduler.py

示例8: test_default_without_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_default_without_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            oobs:
                default:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        oobs_config = yaml.get_section("oobs", brain_config)
        self.assertIsNotNone(oobs_config)

        oob_config = BrainOOBConfiguration("default")
        oob_config.load_config_section(yaml, oobs_config, ".")

        self.assertIsNone(oob_config.classname)
开发者ID:Freiza,项目名称:program-y,代码行数:20,代码来源:test_oob.py

示例9: test_oob_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_oob_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            oobs:
              default:
                classname: programy.oob.default.DefaultOutOfBandProcessor
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        oobs_config = yaml.get_section("oobs", brain_config)
        self.assertIsNotNone(oobs_config)

        oob_config = BrainOOBConfiguration("default")
        oob_config.load_config_section(yaml, oobs_config, ".")

        self.assertEqual("programy.oob.default.DefaultOutOfBandProcessor", oob_config.classname)
开发者ID:Freiza,项目名称:program-y,代码行数:21,代码来源:test_oob.py

示例10: test_with_file_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_file_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            files:
                sets:
                    file: $BOT_ROOT/sets/test.txt
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        files_config = yaml.get_section("files", brain_config)
        self.assertIsNotNone(files_config)

        sets_config = BrainFileConfiguration("sets")
        sets_config.load_config_section(yaml, files_config, ".")

        self.assertEqual("./sets/test.txt", sets_config.file)
开发者ID:Freiza,项目名称:program-y,代码行数:21,代码来源:test_file.py

示例11: test_with_no_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_no_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        tokenizer_config = BrainTokenizerConfiguration()
        tokenizer_config.load_config_section(yaml, brain_config, ".")
开发者ID:Freiza,项目名称:program-y,代码行数:13,代码来源:test_tokenizer.py

示例12: test_authorisation_with_data_neither_denied_srai_or_text

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_authorisation_with_data_neither_denied_srai_or_text(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            security:
                authorisation:
                    classname: programy.security.authorise.passthrough.PassThroughAuthorisationService
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("security", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainSecurityAuthorisationConfiguration()
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual("programy.security.authorise.passthrough.PassThroughAuthorisationService", service_config.classname)
        self.assertEqual(BrainSecurityAuthorisationConfiguration.DEFAULT_ACCESS_DENIED, service_config.denied_text)
        self.assertIsNone(service_config.denied_srai)
开发者ID:Freiza,项目名称:program-y,代码行数:23,代码来源:test_security.py

示例13: test_without_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_without_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            dynamic:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        dynamic_config = BrainDynamicsConfiguration()
        dynamic_config.load_config_section(yaml, brain_config, ".")
开发者ID:Freiza,项目名称:program-y,代码行数:14,代码来源:test_dynamic.py

示例14: test_with_files_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_with_files_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            files:
                aiml:
                    files: $BOT_ROOT/aiml
                    extension: .aiml
                    directories: true
                    errors:
                      file: /tmp/y-bot-errors.txt
                      format: txt
                      encoding: utf-8
                      delete_on_start: true
                    duplicates:
                      file: /tmp/y-bot-duplicates.txt
                      format: txt
                      encoding: utf-8
                      delete_on_start: true
                    conversation:
                      file: /tmp/y-bot-conversation.csv
                      format: csv
                      delete_on_start: true
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        files_config = yaml.get_section("files", brain_config)
        self.assertIsNotNone(files_config)

        aiml_config = BrainAIMLFileConfiguration()
        aiml_config.load_config_section(yaml, files_config, ".")

        self.assertEqual(["./aiml"], aiml_config.files)
        self.assertEqual(".aiml", aiml_config.extension)
        self.assertTrue(aiml_config.directories)
        self.assertEqual("/tmp/y-bot-errors.txt", aiml_config.errors.filename)
        self.assertEqual("/tmp/y-bot-duplicates.txt", aiml_config.duplicates.filename)
        self.assertEqual("/tmp/y-bot-conversation.csv", aiml_config.conversation.filename)
开发者ID:Freiza,项目名称:program-y,代码行数:42,代码来源:test_aimlfile.py

示例15: test_authentication_with_data_denied_text

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import get_section [as 别名]
    def test_authentication_with_data_denied_text(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            security:
                authentication:
                    classname: programy.security.authenticate.passthrough.PassThroughAuthenticationService
                    denied_text: Authentication failed
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("security", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainSecurityAuthenticationConfiguration()
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual("programy.security.authenticate.passthrough.PassThroughAuthenticationService", service_config.classname)
        self.assertEqual("Authentication failed", service_config.denied_text)
        self.assertIsNone(service_config.denied_srai)
开发者ID:Freiza,项目名称:program-y,代码行数:24,代码来源:test_security.py


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