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


Python YamlConfigurationFile.load_from_text方法代码示例

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


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

示例1: test_with_new_format_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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

示例2: test_with_file_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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

示例3: test_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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

示例4: test_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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

示例5: test_init

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [as 别名]
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
            twitter:
              polling_interval: 59
              rate_limit_sleep: 900
              use_status: true
              use_direct_message: true
              auto_follow: true
              storage: file
              storage_location: ./storage/twitter.data
              welcome_message: Thanks for following me
        """, ConsoleConfiguration(), ".")

        twitter_config = TwitterConfiguration()
        twitter_config.load_configuration(yaml, ".")

        self.assertEqual(59, twitter_config.polling_interval)
        self.assertEqual(900, twitter_config.rate_limit_sleep)
        self.assertTrue(twitter_config.use_status)
        self.assertTrue(twitter_config.use_direct_message)
        self.assertTrue(twitter_config.auto_follow)
        self.assertEquals("file", twitter_config.storage)
        self.assertEquals("./storage/twitter.data", twitter_config.storage_location)
        self.assertEquals("Thanks for following me", twitter_config.welcome_message)
开发者ID:Freiza,项目名称:program-y,代码行数:28,代码来源:test_config.py

示例6: test_to_yaml_without_defaults

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [as 别名]
    def test_to_yaml_without_defaults(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
          bot: bot
          default_userid: console
          prompt: $
          license_keys: ./config/license.keys
          bot_selector: programy.clients.client.DefaultBotSelector
          renderer: programy.clients.render.text.TextRenderer
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        data = {}
        config.to_yaml(data, False)

        self.assertEquals('console', data['default_userid'])
        self.assertEquals('$', data['prompt'])

        self.assertEquals(data['bot'], 'bot')
        self.assertEquals(data['license_keys'], "./config/license.keys")
        self.assertEquals(data['bot_selector'], "programy.clients.client.DefaultBotSelector")
        self.assertEquals(data['renderer'], "programy.clients.render.text.TextRenderer")
开发者ID:Freiza,项目名称:program-y,代码行数:28,代码来源:test_config.py

示例7: test_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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

示例8: test_without_data

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

        bot_config = BotConfiguration()
        bot_config.load_configuration(yaml, ".")

        self.assertIsNone(bot_config.brain_selector)
        self.assertEqual("Hello", bot_config.initial_question)
        self.assertEqual("", bot_config.initial_question_srai)
        self.assertEqual("", bot_config.default_response)
        self.assertEqual("", bot_config.default_response_srai)
        self.assertEqual("Bye!", bot_config.exit_response)
        self.assertEqual("", bot_config.exit_response_srai)
        self.assertEqual("", bot_config.empty_string)
        self.assertEqual(bot_config.max_question_recursion, 100)
        self.assertEqual(bot_config.max_question_timeout, -1)
        self.assertEqual(bot_config.max_search_depth, 100)
        self.assertEqual(bot_config.max_search_timeout, -1)
        self.assertTrue(bot_config.override_properties)
        self.assertIsNotNone(bot_config.spelling)
        self.assertIsNotNone(bot_config.conversations)
开发者ID:Freiza,项目名称:program-y,代码行数:27,代码来源:test_bot.py

示例9: test_load_from_configuration_no_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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

示例10: test_with_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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

示例11: test_with_no_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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_init_no_values

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

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        self.assertIsNotNone(config.configurations)
        self.assertEquals(1, len(config.configurations))
开发者ID:Freiza,项目名称:program-y,代码行数:14,代码来源:test_config.py

示例13: test_without_data

# 需要导入模块: from programy.config.file.yaml_file import YamlConfigurationFile [as 别名]
# 或者: from programy.config.file.yaml_file.YamlConfigurationFile import load_from_text [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_init_no_values

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

        twilio_config = TwilioConfiguration()
        twilio_config.load_configuration(yaml, ".")

        self.assertEqual("0.0.0.0", twilio_config.host)
        self.assertEqual(80, twilio_config.port)
        self.assertEqual(False, twilio_config.debug)
开发者ID:Freiza,项目名称:program-y,代码行数:15,代码来源:test_config.py

示例15: test_without_data

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

        bot_config = yaml.get_section("bot")

        convo_config = BotConversationsFileStorageConfiguration(config_name="file_storage")
        convo_config.load_config_section(yaml, bot_config, ".")

        self.assertIsNone(convo_config.dir)
开发者ID:Freiza,项目名称:program-y,代码行数:15,代码来源:test_filestorage.py


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