Author: bugman Date: Mon Nov 30 14:44:05 2009 New Revision: 10026 URL: http://svn.gna.org/viewcvs/relax?rev=10026&view=rev Log: Created the common method _set_param_values_global() for the analysis API. Modified: 1.3/specific_fns/api_common.py Modified: 1.3/specific_fns/api_common.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/api_common.py?rev=10026&r1=10025&r2=10026&view=diff ============================================================================== --- 1.3/specific_fns/api_common.py (original) +++ 1.3/specific_fns/api_common.py Mon Nov 30 14:44:05 2009 @@ -330,6 +330,41 @@ inc = inc + 1 + def _set_param_values_global(self, param=None, value=None, spin_id=None, force=True): + """Set the global parameter values in the top layer of the data pipe. + + @keyword param: The parameter name list. + @type param: list of str + @keyword value: The parameter value list. + @type value: list + @keyword spin_id: The spin identification string (unused). + @type spin_id: None + @keyword force: A flag which if True will cause current values to be overwritten. If False, a RelaxError will raised if the parameter value is already set. + @type force: bool + """ + + # Checks. + arg_check.is_str_list(param, 'parameter name') + arg_check.is_list(value, 'parameter value') + arg_check.is_none(spin_id, 'spin ID string') + + # Loop over the parameters. + for i in range(len(param)): + # Get the object's name. + obj_name = self.return_data_name(param[i]) + + # Is the parameter is valid? + if not obj_name: + raise RelaxError("The parameter '%s' is not valid for this data pipe type." % param[i]) + + # Is the parameter already set. + if not force and hasattr(cdp, obj_name) and getattr(cdp, obj_name) != None: + raise RelaxError("The parameter '%s' already exists, set the force flag to True to overwrite." % param[i]) + + # Set the parameter. + setattr(cdp, obj_name, value[i]) + + def _set_param_values_spin(self, param=None, value=None, spin_id=None, force=True): """Set the spin specific parameter values.