示例#1
0
def _checkAndSetForcedMPICommand(value):
    """ """
    """ Utility function to check validity of input for forced MPI command.
    :param value: The value to check.
    :type value: str
    """

    return checkAndSetInstance(str, value, "")
def checkAndSetBaseCalculator(var=None, default=None):
    """
    Check if passed object is an AbstractBaseCalculator instance. If non is given, set to given default.
    :param var: The object to check.
    :param default: The default to use.
    :return: Te checked photon source object.
    :raises RuntimeError: if no valid BaseCalculator was given.
    """

    return checkAndSetInstance(AbstractBaseCalculator, var, default)
def checkAndSetIO(io):
    """ Check the passed io path/filenames and set appropriately. """

    # Check we have a tuple.
    io = checkAndSetInstance(tuple, io)
    if len(io) != 2:
        raise RuntimeError(
            "The parameter 'io' can only be a tuple of two strings.")

    # Check if input exists, if not, raise.
    i = checkAndSetInstance(str, io[0])
    if i is None:
        raise IOError("The parameter 'input_path' must be a valid filename.")
    i = os.path.abspath(i)
    #
    # Check if output file exists, otherwise attempt to create it.
    o = checkAndSetInstance(str, io[1])
    if o is None:
        raise IOError("The parameter 'output_path' must be a valid filename.")
    o = os.path.abspath(o)

    return (i, o)
 def output_path(self, value):
     """ Set the io path(s) to a value. """
     self.__output_path = checkAndSetInstance((str, list), value, None)
 def parameters(self, value):
     """ Set the control parameters for the calculation. """
     if isinstance(value, AbstractCalculatorParameters):
         self.__parameters = value
         return
     self.__parameters = checkAndSetInstance(dict, value, None)