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


Python Settings.write_settings方法代码示例

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


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

示例1: test_set_config_should_update_value_for_algorithm_to_backtracking

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import write_settings [as 别名]
 def test_set_config_should_update_value_for_algorithm_to_backtracking(self):
     new_default = "Backtracking"
     settings_xml = Settings()
     settings_xml.read_settings_from_file()
     settings_xml.set_config("Algorithm", new_default)
     settings_xml.write_settings()
     settings_xml.read_settings_from_file()
     result = settings_xml.get_name_for_current_setting("Algorithm")
     self.assertEqual(new_default, result)
开发者ID:rsanchezG,项目名称:sudokuB-1,代码行数:11,代码来源:test_settings.py

示例2: test_set_config_should_update_value_for_level_easy_to_max_35

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import write_settings [as 别名]
 def test_set_config_should_update_value_for_level_easy_to_max_35(self):
     setting_node = "Level"
     setting_name = "Easy"
     attribute_name = "max"
     new_attribute_value = "35"
     settings_xml = Settings()
     settings_xml.read_settings_from_file()
     settings_xml.set_config_attributes(setting_node, setting_name, attribute_name, new_attribute_value)
     settings_xml.write_settings()
     settings_xml.read_settings_from_file()
     result = settings_xml.get_attribute_value_for_setting(setting_node, setting_name, attribute_name)
     self.assertEqual(new_attribute_value, result)
开发者ID:rsanchezG,项目名称:sudokuB-1,代码行数:14,代码来源:test_settings.py

示例3: test_sudoku_should_resolve_an_easy_sudoku_with_backtracking_from_TXT_to_result

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import write_settings [as 别名]
 def test_sudoku_should_resolve_an_easy_sudoku_with_backtracking_from_TXT_to_result(self):
     sudoku_test = Sudoku()
     settings_test = Settings()
     expected_result= ["4 8 3 |9 2 1 |6 5 7 \n", \
                       "9 6 7 |3 4 5 |8 2 1 \n", \
                       "2 5 1 |8 7 6 |4 9 3 \n", \
                       "------+------+------\n", \
                       "5 4 8 |1 3 2 |9 7 6 \n", \
                       "7 2 9 |5 6 4 |1 3 8 \n", \
                       "1 3 6 |7 9 8 |2 4 5 \n", \
                       "------+------+------\n", \
                       "3 7 2 |6 8 9 |5 1 4 \n", \
                       "8 1 4 |2 5 3 |7 6 9 \n", \
                       "6 9 5 |4 1 7 |3 8 2 \n"]
     settings_test.set_config("Algorithm", "Backtracking")
     settings_test.set_config("Input", "TXT")
     settings_test.write_settings()
     sudoku_test.start_game()
     file_result = open("../game_results/default.txt", 'r')
     result = file_result.readlines()
     file_result.close()
     self.assertEqual(expected_result, result)
开发者ID:rsanchezG,项目名称:sudokuB-1,代码行数:24,代码来源:test_sudoku.py

示例4: __init__

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import write_settings [as 别名]

#.........这里部分代码省略.........
        if index_setting_number != 0: #0 refers to Algorithm
            self.menu_string += "2. Modify " + setting + " attributes\n"

        self.menu_string = self.menu_string + \
                           "m. Go to main menu\n" + \
                           "x. Exit"
        print self.menu_string

    def display_modify_default_setting(self, setting_to_modify):
        """Display options for setting to be modifed as the method according to user_option value

        Keyword arguments:
        setting_to_modify -- setting used to get a list of different values
        """
        setting = setting_to_modify
        print "\n\nSet default " + setting
        elements = self.sudoku_settings.get_setting_list_to(setting)
        list_of_settings = []
        good_input_values = ""
        counter_index = 1

        for element in elements:
            print str(counter_index)+". " + element.attrib["name"]
            list_of_settings.append(element.attrib["name"])
            good_input_values += "|"+str(counter_index)
            counter_index += 1

        print "m. Go to main menu"
        print "x. Exit"
        self.get_option_value_from_user()

        if self.is_a_valid_option_from_settings(good_input_values) is True:
            self.sudoku_settings.set_config(setting, list_of_settings[int(self.user_option) - 1])
            self.sudoku_settings.write_settings()
        self.status = "m"

    def is_a_valid_option_from_settings(self, good_input_values):
        """Validate a user input value against values that have read from settings
        Keyword arguments:
        good_input_values -- list of different values have read from settings.
        """
        print good_input_values
        patron_input_values = "^(" + self.exit_game_option + "|" + self.go_main_menu_option + \
                              good_input_values + "){1}$"
        print patron_input_values
        if re.match(good_input_values, self.user_option):
            print self.user_option
            if self.user_option == self.exit_game_option or \
               self.user_option == self.go_main_menu_option:
                return False
            return True
        else:
            return False

    def display_select_setting_name_to_modify_attributes(self, setting_to_modify):
        """Display names of setting to modify his attributes

        Keyword arguments:
        setting_to_modify -- setting used to get a list of different values
        """
        setting = setting_to_modify
        print "\n\nSet attributes for " + setting + ":"
        elements = self.sudoku_settings.get_setting_list_to(setting)
        list_of_settings = []
        counter_index = 1
开发者ID:rsanchezG,项目名称:sudokuB-1,代码行数:69,代码来源:menu.py


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