Exemplo n.º 1
0
 def load_from_file(self, filename, client_configuration, bot_root):
     configuration = ProgramrConfiguration(client_configuration)
     with open(filename, 'r+', encoding="utf-8") as xml_data_file:
         tree = ET.parse(xml_data_file, parser=LineNumberingParser())
         self.xml_data = tree.getroot()
         configuration.load_config_data(self, bot_root)
     return configuration
Exemplo n.º 2
0
 def load_from_text(self, text, client_configuration, bot_root):
     self.yaml_data = yaml.load(text)
     if self.yaml_data is None:
         raise Exception("Yaml data is missing")
     configuration = ProgramrConfiguration(client_configuration)
     configuration.load_config_data(self, bot_root)
     return configuration
Exemplo n.º 3
0
    def test_bot_with_config(self):
        configuration = ProgramrConfiguration(ConsoleConfiguration())
        self.assertIsNotNone(configuration)
        self.assertIsNotNone(configuration.client_configuration.brain_config[0])
        self.assertIsNotNone(configuration.client_configuration.brain_config[0].brain_config[0])

        configuration.client_configuration.brain_config[0].prompt = ":"
        configuration.client_configuration.brain_config[0].default_response = "No answer for that"
        configuration.client_configuration.brain_config[0].exit_response = "See ya!"

        bot = Bot(config=configuration.client_configuration.brain_config[0])
        self.assertIsNotNone(bot)

        self.assertEqual(bot.default_response, "No answer for that")
        self.assertEqual(bot.exit_response, "See ya!")
Exemplo n.º 4
0
    def load_configuration(self, arguments):
        if arguments.bot_root is None:
            if arguments.config_filename is not None:
                arguments.bot_root = os.path.dirname(arguments.config_filename)
            else:
                arguments.bot_root = "."

        if arguments.config_filename is not None:
            self._configuration = ConfigurationFactory.load_configuration_from_file(
                self.get_client_configuration(), arguments.config_filename,
                arguments.config_format, arguments.bot_root)
        else:
            print("No configuration file specified, using defaults only !")
            self._configuration = ProgramrConfiguration(
                self.get_client_configuration())
Exemplo n.º 5
0
 def load_from_file(self, filename, client_configuration, bot_root):
     configuration = ProgramrConfiguration(client_configuration)
     with open(filename, 'r+', encoding="utf-8") as yml_data_file:
         self.yaml_data = yaml.load(yml_data_file, Loader=yaml.FullLoader)
         configuration.load_config_data(self, bot_root)
     return configuration
Exemplo n.º 6
0
 def load_from_file(self, filename, client_configuration, bot_root):
     configuration = ProgramrConfiguration(client_configuration)
     with open(filename, 'r+', encoding="utf-8") as json_data_file:
         self.json_data = json.load(json_data_file)
         configuration.load_config_data(self, bot_root)
     return configuration
Exemplo n.º 7
0
 def load_from_text(self, text, client_configuration, bot_root):
     self.json_data = json.loads(text)
     configuration = ProgramrConfiguration(client_configuration)
     configuration.load_config_data(self, bot_root)
     return configuration
Exemplo n.º 8
0
 def load_configuration(self, arguments):
     config = ConsoleConfiguration()
     self._configuration = ProgramrConfiguration(config)
Exemplo n.º 9
0
 def load_from_text(self, text, client_configuration, bot_root):
     tree = ET.fromstring(text)
     self.xml_data = tree
     configuration = ProgramrConfiguration(client_configuration)
     configuration.load_config_data(self, bot_root)
     return configuration
Exemplo n.º 10
0
 def test_programr(self):
     program_config = ProgramrConfiguration(TestConfiguration())
     self.assertIsNotNone(program_config)
     self.assertIsNotNone(program_config.client_configuration)