本文整理汇总了Python中SANSUtility.are_two_files_identical方法的典型用法代码示例。如果您正苦于以下问题:Python SANSUtility.are_two_files_identical方法的具体用法?Python SANSUtility.are_two_files_identical怎么用?Python SANSUtility.are_two_files_identical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SANSUtility
的用法示例。
在下文中一共展示了SANSUtility.are_two_files_identical方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _match_IDF
# 需要导入模块: import SANSUtility [as 别名]
# 或者: from SANSUtility import are_two_files_identical [as 别名]
def _match_IDF(self, run):
'''
Compares the IDF in the stored instrument with the IDF in the workspace.
If they are the same all is well. If they diff, then load the adequate
user file.
@param run: name of the run for which the file is to be extracted
'''
# We need the instrument name and the measurement time to determine
# the IDF
measurement_time = None
instrument_name = self.get_instrument_name()
# We need to be able to handle file-based and workspace-based queries
# If we have a workspace we look at the end time, else we
# need a sophisticated extraction mechanism
if isinstance(run, Workspace):
ws = None
if isinstance(run, WorkspaceGroup):
# Just look at the first element in a workspace group
ws = run[0]
else:
ws = run
measurement_time = str(ws.getRun().endTime()).strip()
else:
if run is None or run == "":
return
measurement_time = su.get_measurement_time_from_file(run)
# Get the path to the instrument definition file
idf_path_workspace = ExperimentInfo.getInstrumentFilename(instrument_name, measurement_time)
idf_path_workspace = os.path.normpath(idf_path_workspace)
# Get the idf from the reducer
idf_path_reducer = self.get_idf_file_path()
idf_path_reducer = os.path.normpath(idf_path_reducer)
# Now check if both idf paths and underlying files. If they are, then don't do anything
# else switch the underlying instrument
if idf_path_reducer == idf_path_workspace and su.are_two_files_identical(idf_path_reducer, idf_path_reducer):
return
else:
logger.notice("Updating the IDF of the Reducer. Switching from " +
str(idf_path_reducer) + " to " + str(idf_path_workspace))
idf_path = os.path.basename(idf_path_workspace)
instrument = self._get_correct_instrument(instrument_name, idf_path)
# Get detector of the old instrument
old_instrument = self.get_instrument()
old_detector_selection = old_instrument.get_detector_selection()
if instrument is not None:
self.set_instrument(instrument)
# We need to update the instrument, by reloading the user file.
# This is pretty bad, but looking at the reducer architecture this
# seems to be the only reasonable way to do this.
self.user_settings.execute(self)
# Now we set the correct detector, this is also being done in the GUI
self.get_instrument().setDetector(old_detector_selection)