Ejemplo n.º 1
0
    def to_yaml(self, data, defaults=True):
        if defaults is True:
            data['denormal'] = "./config/denormal.txt"
            data['normal'] = "./config/normal.txt"
            data['gender'] = "./config/gender.txt"
            data['person'] = "./config/person.txt"
            data['person2'] = "./config/person2.txt"
            data['properties'] = "./config/properties.txt"
            data['variables'] = "./config/variables.txt"
            data['triples'] = "./config/triples.txt"
            data['preprocessors'] = "./config/preprocessors.txt"
            data['postprocessors'] = "./config/postprocessors.txt"
            data['regex_templates'] = "./config/regex.txt"
        else:
            data['denormal'] = self._denormal
            data['normal'] = self._normal
            data['gender'] = self._gender
            data['person'] = self._person
            data['person2'] = self._person2
            data['properties'] = self._properties
            data['variables'] = self._variables
            data['triples'] = self._triples
            data['preprocessors'] = self._preprocessors
            data['postprocessors'] = self._postprocessors
            data['regex_templates'] = self._regex_templates

        self.config_to_yaml(data, BrainAIMLFileConfiguration(), defaults)
        self.config_to_yaml(data, BrainFileConfiguration("sets"), defaults)
        self.config_to_yaml(data, BrainFileConfiguration("maps"), defaults)
        self.config_to_yaml(data, BrainFileConfiguration("rdf"), defaults)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    def __init__(self):
        BaseSectionConfigurationData.__init__(self, "files")
        self._aiml_files = BrainAIMLFileConfiguration()
        self._set_files = BrainFileConfiguration("sets")
        self._map_files = BrainFileConfiguration("maps")
        self._rdf_files = BrainFileConfiguration("rdf")

        self._denormal = None
        self._normal = None
        self._gender = None
        self._person = None
        self._person2 = None
        self._properties = None
        self._variables = None
        self._triples = None
        self._preprocessors = None
        self._postprocessors = None
        self._regex_templates = None
Ejemplo n.º 4
0
    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)