Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    def test_to_yaml_no_defaults_no_data(self):
        yaml = {}
        dynamic_config = BrainDynamicsConfiguration()
        dynamic_config.to_yaml(yaml, defaults=False)

        self.assertEquals({}, yaml['variables'])
        self.assertEquals({},  yaml['sets'])
        self.assertEquals({},  yaml['maps'])
Exemple #4
0
 def __init__(self, section_name="brain"):
     self._overrides = BrainOverridesConfiguration()
     self._defaults = BrainDefaultsConfiguration()
     self._binaries = BrainBinariesConfiguration()
     self._braintree = BrainBraintreeConfiguration()
     self._security = BrainSecuritiesConfiguration()
     self._dynamics = BrainDynamicsConfiguration()
     self._tokenizer = BrainTokenizerConfiguration()
     self._debugfiles = BrainDebugFilesConfiguration()
     BaseContainerConfigurationData.__init__(self, section_name)
Exemple #5
0
    def test_with_no_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        dynamic_config = BrainDynamicsConfiguration()
        dynamic_config.load_config_section(yaml, brain_config, ".")
Exemple #6
0
    def test_with_no_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        dynamic_config = BrainDynamicsConfiguration()
        dynamic_config.load_config_section(yaml, brain_config, ".")
Exemple #7
0
    def test_to_yaml_defaults(self):
        yaml = {}
        dynamic_config = BrainDynamicsConfiguration()
        dynamic_config.to_yaml(yaml, defaults=True)

        self.assertEquals({'GETTIME': 'programy.dynamic.variables.datetime.GetTime'}, yaml['variables'])
        self.assertEquals({'NUMBER': 'programy.dynamic.sets.numeric.IsNumeric',
                           'ROMAN': 'programy.dynamic.sets.roman.IsRomanNumeral',
                           'STOPWORD': 'programy.dynamic.sets.stopword.IsStopWord',
                           'SYNSETS': 'programy.dynamic.sets.synsets.IsSynset'},  yaml['sets'])
        self.assertEquals({'ROMANTODDEC': 'programy.dynamic.maps.roman.MapRomanToDecimal',
                           'DECTOROMAN': 'programy.dynamic.maps.roman.MapDecimalToRoman',
                           'LEMMATIZE': 'programy.dynamic.maps.lemmatize.LemmatizeMap',
                           'STEMMER': 'programy.dynamic.maps.stemmer.StemmerMap'},  yaml['maps'])
Exemple #8
0
    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, ".")

        self.assertEquals({}, dynamic_config.dynamic_vars)
        self.assertEquals({}, dynamic_config.dynamic_sets)
        self.assertEquals({}, dynamic_config.dynamic_maps)
Exemple #9
0
    def __init__(self, section_name="brain"):
        self._bot_name = None
        self._manager_name = None

        self._overrides = BrainOverridesConfiguration()
        self._defaults = BrainDefaultsConfiguration()
        self._binaries = BrainBinariesConfiguration()
        self._braintree = BrainBraintreeConfiguration()
        self._services = BrainServicesConfiguration()
        self._security = BrainSecuritiesConfiguration()
        self._oob = BrainOOBSConfiguration()
        self._dynamics = BrainDynamicsConfiguration()
        self._tokenizer = BrainTokenizerConfiguration()
        self._debugfiles = BrainDebugFilesConfiguration()
        self._nlu = BrainNluConfiguration()
        BaseContainerConfigurationData.__init__(self, section_name)
Exemple #10
0
 def to_yaml(self, data, defaults=True):
     self.config_to_yaml(data, BrainOverridesConfiguration(), defaults)
     self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults)
     self.config_to_yaml(data, BrainBinariesConfiguration(), defaults)
     self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults)
     self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults)
     self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults)
     self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults)
     self.config_to_yaml(data, BrainDebugFilesConfiguration(), defaults)
Exemple #11
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            dynamic:
                variables:
                    gettime: programy.dynamic.variables.datetime.GetTime
                sets:
                    number: programy.dynamic.sets.numeric.IsNumeric
                    roman:   programy.dynamic.sets.roman.IsRomanNumeral
                maps:
                    romantodec: programy.dynamic.maps.roman.MapRomanToDecimal
                    dectoroman: programy.dynamic.maps.roman.MapDecimalToRoman
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        dynamic_config = BrainDynamicsConfiguration()
        dynamic_config.load_config_section(yaml, brain_config, ".")
Exemple #12
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            dynamic:
                variables:
                    gettime: programy.dynamic.variables.datetime.GetTime
                sets:
                    number: programy.dynamic.sets.numeric.IsNumeric
                    roman:   programy.dynamic.sets.roman.IsRomanNumeral
                maps:
                    romantodec: programy.dynamic.maps.roman.MapRomanToDecimal
                    dectoroman: programy.dynamic.maps.roman.MapDecimalToRoman
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        dynamic_config = BrainDynamicsConfiguration()
        dynamic_config.load_config_section(yaml, brain_config, ".")
Exemple #13
0
    def test_to_yaml_no_defaults(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            dynamic:
                variables:
                    gettime: programy.dynamic.variables.datetime.GetTime
                sets:
                    number: programy.dynamic.sets.numeric.IsNumeric
                    roman:   programy.dynamic.sets.roman.IsRomanNumeral
                maps:
                    romantodec: programy.dynamic.maps.roman.MapRomanToDecimal
                    dectoroman: programy.dynamic.maps.roman.MapDecimalToRoman
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

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

        data = {}
        dynamic_config.to_yaml(data, defaults=False)

        self.assertEquals({'GETTIME': 'programy.dynamic.variables.datetime.GetTime'}, data['variables'])
        self.assertEquals({'NUMBER': 'programy.dynamic.sets.numeric.IsNumeric', 'ROMAN': 'programy.dynamic.sets.roman.IsRomanNumeral'}, data['sets'])
        self.assertEquals({'ROMANTODEC': 'programy.dynamic.maps.roman.MapRomanToDecimal', 'DECTOROMAN': 'programy.dynamic.maps.roman.MapDecimalToRoman'}, data['maps'])
Exemple #14
0
 def __init__(self, section_name="brain"):
     self._overrides = BrainOverridesConfiguration()
     self._defaults = BrainDefaultsConfiguration()
     self._nodes = BrainNodesConfiguration()
     self._binaries = BrainBinariesConfiguration()
     self._braintree = BrainBraintreeConfiguration()
     self._files = BrainFilesConfiguration()
     self._services = BrainServicesConfiguration()
     self._security = BrainSecuritiesConfiguration()
     self._oob = BrainOOBSConfiguration()
     self._dynamics = BrainDynamicsConfiguration()
     self._tokenizer = BrainTokenizerConfiguration()
     BaseContainerConfigurationData.__init__(self, section_name)
Exemple #15
0
    def test_load_from_configuration(self):
        collection = DynamicsCollection()
        self.assertIsNotNone(collection)

        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            dynamic:
                variables:
                    gettime: programy.dynamic.variables.datetime.GetTime
                sets:
                    roman: programy.dynamic.sets.roman.IsRomanNumeral
                maps:
                    romantodec: programy.dynamic.maps.roman.MapRomanToDecimal
        """, 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("ROMAN"))
        self.assertTrue(collection.is_dynamic_set("NUMBER"))

        self.assertIsNotNone(collection.dynamic_maps)
        self.assertTrue(collection.is_dynamic_map("ROMANTODEC"))
        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)
        self.assertTrue(collection.is_dynamic_var("GETTIME"))
Exemple #16
0
    def test_load_from_configuration(self):
        collection = DynamicsCollection()
        self.assertIsNotNone(collection)

        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            dynamic:
                variables:
                    gettime: programy.dynamic.variables.datetime.GetTime
                sets:
                    roman: programy.dynamic.sets.roman.IsRomanNumeral
                maps:
                    romantodec: programy.dynamic.maps.roman.MapRomanToDecimal
        """, 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("ROMAN"))
        self.assertTrue(collection.is_dynamic_set("NUMBER"))

        self.assertIsNotNone(collection.dynamic_maps)
        self.assertTrue(collection.is_dynamic_map("ROMANTODEC"))
        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)
        self.assertTrue(collection.is_dynamic_var("GETTIME"))
Exemple #17
0
class BrainConfiguration(BaseContainerConfigurationData):
    def __init__(self, section_name="brain"):
        self._bot_name = None
        self._manager_name = None

        self._overrides = BrainOverridesConfiguration()
        self._defaults = BrainDefaultsConfiguration()
        self._binaries = BrainBinariesConfiguration()
        self._braintree = BrainBraintreeConfiguration()
        self._services = BrainServicesConfiguration()
        self._security = BrainSecuritiesConfiguration()
        self._oob = BrainOOBSConfiguration()
        self._dynamics = BrainDynamicsConfiguration()
        self._tokenizer = BrainTokenizerConfiguration()
        self._debugfiles = BrainDebugFilesConfiguration()
        self._nlu = BrainNluConfiguration()
        BaseContainerConfigurationData.__init__(self, section_name)

    @property
    def bot_name(self):
        return self._bot_name

    @property
    def manager_name(self):
        return self._manager_name

    @property
    def overrides(self):
        return self._overrides

    @property
    def defaults(self):
        return self._defaults

    @property
    def binaries(self):
        return self._binaries

    @property
    def braintree(self):
        return self._braintree

    @property
    def services(self):
        return self._services

    @property
    def security(self):
        return self._security

    @property
    def oob(self):
        return self._oob

    @property
    def dynamics(self):
        return self._dynamics

    @property
    def tokenizer(self):
        return self._tokenizer

    @property
    def debugfiles(self):
        return self._debugfiles

    @property
    def nlu(self):
        return self._nlu

    def check_for_license_keys(self, license_keys):
        self._overrides.check_for_license_keys(license_keys)
        self._defaults.check_for_license_keys(license_keys)
        self._binaries.check_for_license_keys(license_keys)
        self._braintree.check_for_license_keys(license_keys)
        self._services.check_for_license_keys(license_keys)
        self._security.check_for_license_keys(license_keys)
        self._oob.check_for_license_keys(license_keys)
        self._dynamics.check_for_license_keys(license_keys)
        self._tokenizer.check_for_license_keys(license_keys)
        self._debugfiles.check_for_license_keys(license_keys)
        self._nlu.check_for_license_keys(license_keys)
        BaseContainerConfigurationData.check_for_license_keys(
            self, license_keys)

    def load_configuration(self,
                           configuration_file,
                           bot_root,
                           subs: Substitutions = None):
        brain_config = configuration_file.get_section(self.section_name)
        if brain_config is not None:
            self._bot_name = configuration_file.get_option(
                brain_config, "bot_name")
            self._manager_name = configuration_file.get_option(
                brain_config, "manager_name")

            self._overrides.load_config_section(configuration_file,
                                                brain_config,
                                                bot_root,
                                                subs=subs)
            self._defaults.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._binaries.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._braintree.load_config_section(configuration_file,
                                                brain_config,
                                                bot_root,
                                                subs=subs)
            self._services.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._security.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._oob.load_config_section(configuration_file,
                                          brain_config,
                                          bot_root,
                                          subs=subs)
            self._dynamics.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._tokenizer.load_config_section(configuration_file,
                                                brain_config,
                                                bot_root,
                                                subs=subs)
            self._debugfiles.load_config_section(configuration_file,
                                                 brain_config,
                                                 bot_root,
                                                 subs=subs)
            self._nlu.load_config_section(configuration_file,
                                          brain_config,
                                          bot_root,
                                          subs=subs)

    def to_yaml(self, data, defaults=True):
        self.config_to_yaml(data, BrainOverridesConfiguration(), defaults)
        self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults)
        self.config_to_yaml(data, BrainBinariesConfiguration(), defaults)
        self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults)
        self.config_to_yaml(data, BrainServicesConfiguration(), defaults)
        self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults)
        self.config_to_yaml(data, BrainOOBSConfiguration(), defaults)
        self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults)
        self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults)
        self.config_to_yaml(data, BrainDebugFilesConfiguration(), defaults)
        self.config_to_yaml(data, BrainNluConfiguration(), defaults)
Exemple #18
0
class BrainConfiguration(BaseContainerConfigurationData):
    def __init__(self, section_name="brain"):
        self._overrides = BrainOverridesConfiguration()
        self._defaults = BrainDefaultsConfiguration()
        self._binaries = BrainBinariesConfiguration()
        self._braintree = BrainBraintreeConfiguration()
        self._services = BrainServicesConfiguration()
        self._openchatbots = BrainOpenChatBotsConfiguration()
        self._security = BrainSecuritiesConfiguration()
        self._dynamics = BrainDynamicsConfiguration()
        self._tokenizer = BrainTokenizerConfiguration()
        self._debugfiles = BrainDebugFilesConfiguration()
        BaseContainerConfigurationData.__init__(self, section_name)

    @property
    def overrides(self):
        return self._overrides

    @property
    def defaults(self):
        return self._defaults

    @property
    def binaries(self):
        return self._binaries

    @property
    def braintree(self):
        return self._braintree

    @property
    def services(self):
        return self._services

    @property
    def openchatbots(self):
        return self._openchatbots

    @property
    def security(self):
        return self._security

    @property
    def dynamics(self):
        return self._dynamics

    @property
    def tokenizer(self):
        return self._tokenizer

    @property
    def debugfiles(self):
        return self._debugfiles

    def check_for_license_keys(self, license_keys):
        self._overrides.check_for_license_keys(license_keys)
        self._defaults.check_for_license_keys(license_keys)
        self._binaries.check_for_license_keys(license_keys)
        self._braintree.check_for_license_keys(license_keys)
        self._services.check_for_license_keys(license_keys)
        self._openchatbots.check_for_license_keys(license_keys)
        self._security.check_for_license_keys(license_keys)
        self._dynamics.check_for_license_keys(license_keys)
        self._tokenizer.check_for_license_keys(license_keys)
        self._debugfiles.check_for_license_keys(license_keys)
        BaseContainerConfigurationData.check_for_license_keys(
            self, license_keys)

    def load_configuration(self,
                           configuration_file,
                           brain_config,
                           bot_root,
                           subs: Substitutions = None):
        if brain_config is not None:
            self._overrides.load_config_section(configuration_file,
                                                brain_config,
                                                bot_root,
                                                subs=subs)
            self._defaults.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._binaries.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._braintree.load_config_section(configuration_file,
                                                brain_config,
                                                bot_root,
                                                subs=subs)
            self._services.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._openchatbots.load_config_section(configuration_file,
                                                   brain_config,
                                                   bot_root,
                                                   subs=subs)
            self._security.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._dynamics.load_config_section(configuration_file,
                                               brain_config,
                                               bot_root,
                                               subs=subs)
            self._tokenizer.load_config_section(configuration_file,
                                                brain_config,
                                                bot_root,
                                                subs=subs)
            self._debugfiles.load_config_section(configuration_file,
                                                 brain_config,
                                                 bot_root,
                                                 subs=subs)

    def to_yaml(self, data, defaults=True):
        self.config_to_yaml(data, BrainOverridesConfiguration(), defaults)
        self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults)
        self.config_to_yaml(data, BrainBinariesConfiguration(), defaults)
        self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults)
        self.config_to_yaml(data, BrainServicesConfiguration(), defaults)
        self.config_to_yaml(data, BrainOpenChatBotsConfiguration(), defaults)
        self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults)
        self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults)
        self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults)
        self.config_to_yaml(data, BrainDebugFilesConfiguration(), defaults)
Exemple #19
0
class BrainConfiguration(BaseContainerConfigurationData):
    def __init__(self, section_name="brain"):
        self._overrides = BrainOverridesConfiguration()
        self._defaults = BrainDefaultsConfiguration()
        self._nodes = BrainNodesConfiguration()
        self._binaries = BrainBinariesConfiguration()
        self._braintree = BrainBraintreeConfiguration()
        self._files = BrainFilesConfiguration()
        self._services = BrainServicesConfiguration()
        self._security = BrainSecuritiesConfiguration()
        self._oob = BrainOOBSConfiguration()
        self._dynamics = BrainDynamicsConfiguration()
        self._tokenizer = BrainTokenizerConfiguration()
        BaseContainerConfigurationData.__init__(self, section_name)

    @property
    def overrides(self):
        return self._overrides

    @property
    def defaults(self):
        return self._defaults

    @property
    def nodes(self):
        return self._nodes

    @property
    def binaries(self):
        return self._binaries

    @property
    def braintree(self):
        return self._braintree

    @property
    def files(self):
        return self._files

    @property
    def services(self):
        return self._services

    @property
    def security(self):
        return self._security

    @property
    def oob(self):
        return self._oob

    @property
    def dynamics(self):
        return self._dynamics

    @property
    def tokenizer(self):
        return self._tokenizer

    def load_configuration(self, configuration_file, bot_root):
        brain_config = configuration_file.get_section(self.section_name)
        if brain_config is not None:
            self._overrides.load_config_section(configuration_file,
                                                brain_config, bot_root)
            self._defaults.load_config_section(configuration_file,
                                               brain_config, bot_root)
            self._nodes.load_config_section(configuration_file, brain_config,
                                            bot_root)
            self._binaries.load_config_section(configuration_file,
                                               brain_config, bot_root)
            self._braintree.load_config_section(configuration_file,
                                                brain_config, bot_root)
            self._files.load_config_section(configuration_file, brain_config,
                                            bot_root)
            self._services.load_config_section(configuration_file,
                                               brain_config, bot_root)
            self._security.load_config_section(configuration_file,
                                               brain_config, bot_root)
            self._oob.load_config_section(configuration_file, brain_config,
                                          bot_root)
            self._dynamics.load_config_section(configuration_file,
                                               brain_config, bot_root)
            self._tokenizer.load_config_section(configuration_file,
                                                brain_config, bot_root)

    def to_yaml(self, data, defaults=True):
        self.config_to_yaml(data, BrainOverridesConfiguration(), defaults)
        self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults)
        self.config_to_yaml(data, BrainNodesConfiguration(), defaults)
        self.config_to_yaml(data, BrainBinariesConfiguration(), defaults)
        self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults)
        self.config_to_yaml(data, BrainFilesConfiguration(), defaults)
        self.config_to_yaml(data, BrainServicesConfiguration(), defaults)
        self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults)
        self.config_to_yaml(data, BrainOOBSConfiguration(), defaults)
        self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults)
        self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults)
Exemple #20
0
    def test_defaults(self):
        dynamic_config = BrainDynamicsConfiguration()
        data = {}
        dynamic_config.to_yaml(data, True)

        BrainDynamicsConfigurationTests.assert_defaults(self, data)
Exemple #21
0
class BrainConfiguration(BaseContainerConfigurationData):

    def __init__(self, section_name="brain"):
        self._overrides = BrainOverridesConfiguration()
        self._defaults = BrainDefaultsConfiguration()
        self._nodes = BrainNodesConfiguration()
        self._binaries = BrainBinariesConfiguration()
        self._braintree = BrainBraintreeConfiguration()
        self._files = BrainFilesConfiguration()
        self._services = BrainServicesConfiguration()
        self._security = BrainSecuritiesConfiguration()
        self._oob = BrainOOBSConfiguration()
        self._dynamics = BrainDynamicsConfiguration()
        self._tokenizer = BrainTokenizerConfiguration()
        BaseContainerConfigurationData.__init__(self, section_name)

    @property
    def overrides(self):
        return self._overrides

    @property
    def defaults(self):
        return self._defaults

    @property
    def nodes(self):
        return self._nodes

    @property
    def binaries(self):
        return self._binaries

    @property
    def braintree(self):
        return self._braintree

    @property
    def files(self):
        return self._files

    @property
    def services(self):
        return self._services

    @property
    def security(self):
        return self._security

    @property
    def oob(self):
        return self._oob

    @property
    def dynamics(self):
        return self._dynamics

    @property
    def tokenizer(self):
        return self._tokenizer

    def load_configuration(self, configuration_file, bot_root):
        brain_config = configuration_file.get_section(self.section_name)
        if brain_config is not None:
            self._overrides.load_config_section(configuration_file, brain_config, bot_root)
            self._defaults.load_config_section(configuration_file, brain_config, bot_root)
            self._nodes.load_config_section(configuration_file, brain_config, bot_root)
            self._binaries.load_config_section(configuration_file, brain_config, bot_root)
            self._braintree.load_config_section(configuration_file, brain_config, bot_root)
            self._files.load_config_section(configuration_file, brain_config, bot_root)
            self._services.load_config_section(configuration_file, brain_config, bot_root)
            self._security.load_config_section(configuration_file, brain_config, bot_root)
            self._oob.load_config_section(configuration_file, brain_config, bot_root)
            self._dynamics.load_config_section(configuration_file, brain_config, bot_root)
            self._tokenizer.load_config_section(configuration_file, brain_config, bot_root)

    def to_yaml(self, data, defaults=True):
        self.config_to_yaml(data, BrainOverridesConfiguration(), defaults)
        self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults)
        self.config_to_yaml(data, BrainNodesConfiguration(), defaults)
        self.config_to_yaml(data, BrainBinariesConfiguration(), defaults)
        self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults)
        self.config_to_yaml(data, BrainFilesConfiguration(), defaults)
        self.config_to_yaml(data, BrainServicesConfiguration(), defaults)
        self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults)
        self.config_to_yaml(data, BrainOOBSConfiguration(), defaults)
        self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults)
        self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults)