Skip to content

Commit

Permalink
Re #11063 method returns all file-dependent properties needing
Browse files Browse the repository at this point in the history
validation
  • Loading branch information
abuts committed Feb 11, 2015
1 parent d5a56e3 commit f5ac56e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
38 changes: 36 additions & 2 deletions Code/Mantid/scripts/Inelastic/Direct/PropertyManager.py
Expand Up @@ -273,8 +273,6 @@ def set_input_parameters_ignore_nan(self,**kwargs):
if not(value is None):
setattr(self,par_name,value)



def set_input_parameters(self,**kwargs):
""" Set input properties from a dictionary of parameters
Expand Down Expand Up @@ -491,13 +489,49 @@ def _check_file_exist(self,file_name):
except:
file_path =''

def _get_properties_with_files(self):
""" Method returns list of properties, with values may have
files corresponding to them
it does not include sample run, as this one will be
treated separately
"""

run_files_prop=['wb_run','monovan_run','mask_run','wb_for_monovan_run','second_white']
map_mask_prop =['det_cal_file','map_file','hard_mask_file']

abs_units = not(self.monovan_run is None)
run_files_to_check =[]
for prop_name in run_files_prop:
theProp = getattr(PropertyManager,prop_name)
if theProp.has_own_value:
val = theProp.__get__(self,PropertyManager)
if isinstance(val,api.Workspace): # it is loaded workspace
continue # and we do not care if
else: # it have file
if not(val is None) :
run_files_to_check.append(prop_name)
# other files to check:
aux_files_to_check=[]
for prop_name in map_mask_prop:
val = getattr(self,prop_name)
if not(val is None):
aux_files_to_check.append(prop_name)
if abs_units:
val = self.monovan_mapfile
if not(val is None) :
aux_files_to_check.append('monovan_mapfile')
#
return run_files_to_check,aux_files_to_check


def _check_necessary_files(self,monovan_run):
""" Method verifies if all files necessary for a run are available.
useful for long runs to check if all files necessary for it are present/accessible
"""


def check_files_list(files_list):
file_missing = False
for prop in files_list :
Expand Down
15 changes: 13 additions & 2 deletions Code/Mantid/scripts/Inelastic/Direct/RunDescriptor.py
Expand Up @@ -437,8 +437,8 @@ def find_file(self,inst_name=None,run_num=None,filePath=None,fileExt=None,**kwar
fname,fex = os.path.splitext(file)
self._run_ext = fex
if old_ext != fex:
message = ' Cannot find run-file with extension {0}.\n'\
' Found file {1} instead'.format(old_ext,file)
message = '*** Cannot find run-file with extension {0}.\n'\
' Found file {1} instead'.format(old_ext,file)
RunDescriptor._logger(message,'notice')
self._run_file_path = os.path.dirname(fname)
return file
Expand Down Expand Up @@ -661,6 +661,12 @@ def _clear_old_ws(self,old_ws_name,new_name,clear_fext=False):
self._run_ext = None
self._run_file_path = ''

def has_own_value(self):
""" interface property, used in conjunction with
RunDescriptorDependent property. Always true as
RunDescriptor property always have own value
"""
return True

#-------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -693,6 +699,11 @@ def __set__(self,instance,value):
self._this_run_defined = True
super(RunDescriptorDependent,self).__set__(instance,value)

def has_own_value(self):
""" returns true if the property got own value and
is not bind to parent's value any more
"""
return self._this_run_defined
#def __del__(self):
# # destructor removes bounded workspace
# # Probably better not to at current approach
Expand Down

0 comments on commit f5ac56e

Please sign in to comment.