本文整理汇总了Python中settings.Settings.set_config方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.set_config方法的具体用法?Python Settings.set_config怎么用?Python Settings.set_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.set_config方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_config_should_update_value_for_algorithm_to_backtracking
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set_config [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)
示例2: test_sudoku_should_resolve_an_easy_sudoku_with_backtracking_from_TXT_to_result
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set_config [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)
示例3: __init__
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import set_config [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