本文整理汇总了Python中SANSUtility.get_user_file_name_options_with_txt_extension方法的典型用法代码示例。如果您正苦于以下问题:Python SANSUtility.get_user_file_name_options_with_txt_extension方法的具体用法?Python SANSUtility.get_user_file_name_options_with_txt_extension怎么用?Python SANSUtility.get_user_file_name_options_with_txt_extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SANSUtility
的用法示例。
在下文中一共展示了SANSUtility.get_user_file_name_options_with_txt_extension方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUserFileInBatchMode
# 需要导入模块: import SANSUtility [as 别名]
# 或者: from SANSUtility import get_user_file_name_options_with_txt_extension [as 别名]
def setUserFileInBatchMode(new_user_file, current_user_file, original_user_file, original_settings, original_prop_man_settings):
"""
Loads a specified user file. The file is loaded if
new_user_file is different from current_user_file. Else we just
keep the user file loaded. If the new_user_file is empty then we default to
original_user_file.
@param new_user_file: The new user file. Note that this can be merely the filename (+ extension)
@param current_user_file: The currently loaded user file
@param original_user_file: The originally loaded user file. This is used as a default
@param original_settings: The original reducer
@param original_prop_man_settings: Original properties settings
"""
user_file_to_set = ""
if new_user_file == '':
user_file_to_set = original_user_file
else:
# Try to find the user file in the default paths
if not os.path.isfile(new_user_file):
# Find the user file in the Mantid path. we make sure that the user file has a txt extension.
user_file_names_with_extension = su.get_user_file_name_options_with_txt_extension(new_user_file)
for user_file_name_with_extension in user_file_names_with_extension:
user_file = FileFinder.getFullPath(user_file_name_with_extension)
if user_file:
break
if not os.path.isfile(user_file):
message = "Error could not find specified user file {0}"\
.format(new_user_file)
raise RuntimeError(message)
else:
user_file_to_set = user_file
else:
user_file_to_set = new_user_file
# Set the user file in the reducer and load the user file
if os.path.normpath(user_file_to_set) != os.path.normpath(current_user_file):
# Need to setup a clean reducer. If we are dealing with the original user file,
# then we should take gui changes into account, ie reset to the original reducer
if user_file_to_set == original_user_file:
ReductionSingleton().replace(copy.deepcopy(original_settings))
ReductionSingleton().settings = original_prop_man_settings.clone(REDUCTION_SETTINGS_OBJ_NAME)
else:
instrument = copy.deepcopy(ReductionSingleton().get_instrument())
output_type = ReductionSingleton().to_Q.output_type
ReductionSingleton().clean(isis_reducer.ISISReducer)
ReductionSingleton().set_instrument(instrument)
ReductionSingleton().user_settings = UserFile(user_file_to_set)
ReductionSingleton().to_Q.output_type = output_type
ReductionSingleton().user_settings.execute(ReductionSingleton())
current_user_file = user_file_to_set
return current_user_file