예제 #1
0
def _coerce_interval_list(value, keys, args, back_comp_unit_factor=1):
    """Coerce a list of intervals (or numbers: back-comp) into seconds."""
    values_list = _strip_and_unquote_list(keys, value)
    type_converter = (lambda v: _coerce_interval(
        v, keys, args, back_comp_unit_factor=back_comp_unit_factor))
    seconds_list = _expand_list(values_list, keys, type_converter, True)
    return seconds_list
예제 #2
0
파일: utils.py 프로젝트: arjclark/cylc
def coerce_interval_list(value, keys, args):
    """Coerce a list of intervals (or numbers: back-comp) into seconds."""
    return _expand_list(
        _strip_and_unquote_list(keys, value),
        keys,
        lambda v: coerce_interval(v, keys, args),
        True
    )
예제 #3
0
def coerce_interval_list(value, keys, args):
    """Coerce a list of intervals (or numbers: back-comp) into seconds."""
    return _expand_list(
        _strip_and_unquote_list(keys, value),
        keys,
        lambda v: coerce_interval(v, keys, args),
        True
    )
예제 #4
0
def coerce_interval_list(value,
                         keys,
                         args,
                         back_comp_unit_factor=1,
                         check_syntax_version=True):
    """Coerce a list of intervals (or numbers: back-comp) into seconds."""
    return _expand_list(
        _strip_and_unquote_list(keys, value), keys, lambda v: coerce_interval(
            v, keys, args, back_comp_unit_factor, check_syntax_version), True)
예제 #5
0
def coerce_interval_list(
        value, keys, args, back_comp_unit_factor=1, check_syntax_version=True):
    """Coerce a list of intervals (or numbers: back-comp) into seconds."""
    return _expand_list(
        _strip_and_unquote_list(keys, value),
        keys,
        lambda v: coerce_interval(
            v, keys, args, back_comp_unit_factor, check_syntax_version),
        True)
예제 #6
0
파일: suite.py 프로젝트: dmanubens/cylc
def _coerce_interval_list( value, keys, args, back_comp_unit_factor=1 ):
    """Coerce a list of intervals (or numbers: back-comp) into seconds."""
    values_list = _strip_and_unquote_list( keys, value )
    type_converter = (
        lambda v: _coerce_interval(
            v, keys, args,
            back_comp_unit_factor=back_comp_unit_factor
        )
    )
    seconds_list = _expand_list( values_list, keys, type_converter, True )
    return seconds_list
예제 #7
0
파일: suite.py 프로젝트: trwhitcomb/cylc
def _coerce_parameter_list(value, keys, _):
    """Coerce parameter list."""
    value = _strip_and_unquote_list(keys, value)
    if len(value) == 1:
        # May be a range e.g. '1..5' (bounds inclusive)
        try:
            lower, upper = REC_PARAM_INT_RANGE.match(value[0]).groups()
        except AttributeError:
            if "." in value[0]:
                # Dot is illegal in node names, probably bad range syntax.
                raise IllegalValueError("parameter", keys, value)
        else:
            n_dig = len(upper)
            return [str(i).zfill(n_dig) for i in range(int(lower), int(upper) + 1)]
    return value
예제 #8
0
파일: suite.py 프로젝트: rbaumert/cylc
def _coerce_parameter_list(value, keys, _):
    """Coerce parameter list."""
    value = _strip_and_unquote_list(keys, value)
    if len(value) == 1:
        # May be a range e.g. '1..5' (bounds inclusive)
        try:
            lower, upper = REC_PARAM_INT_RANGE.match(value[0]).groups()
        except AttributeError:
            if '.' in value[0]:
                # Dot is illegal in node names, probably bad range syntax.
                raise IllegalValueError("parameter", keys, value)
        else:
            n_dig = len(upper)
            return [
                str(i).zfill(n_dig) for i in range(int(lower),
                                                   int(upper) + 1)
            ]
    return value
예제 #9
0
파일: suite.py 프로젝트: wenlien/cylc
def _coerce_parameter_list(value, keys, _):
    """Coerce parameter list

    Can be:
    * A list of str values. Each str value must conform to the same restriction
      as a task name. Return list of str values.
    * A mixture of int ranges and int values. Return list of str values
      containing the sorted int list, zero-padded to the same width.

    Raise IllegalValueError if:
    * Mixing str and int range.
    * A str value breaks the task name restriction.
    """
    items = []
    can_only_be = None  # A flag to prevent mixing str and int range
    for item in _strip_and_unquote_list(keys, value):
        match = REC_PARAM_INT_RANGE.match(item)
        if match:
            if can_only_be == str:
                raise IllegalValueError('parameter', keys, value,
                                        'mixing int range and str')
            can_only_be = int
            lower, upper, step = match.groups()
            if not step:
                step = 1
            items.extend(range(int(lower), int(upper) + 1, int(step)))
        elif TaskID.NAME_SUFFIX_REC.match(item):
            if not item.isdigit():
                if can_only_be == int:
                    raise IllegalValueError('parameter', keys, value,
                                            'mixing int range and str')
                can_only_be = str
            items.append(item)
        else:
            raise IllegalValueError('parameter', keys, value,
                                    '%s: bad value' % item)
    if not items or can_only_be == str or any(not str(item).isdigit()
                                              for item in items):
        return items
    else:
        return [int(item) for item in items]
예제 #10
0
파일: suite.py 프로젝트: arjclark/cylc
def _coerce_parameter_list(value, keys, _):
    """Coerce parameter list

    Can be:
    * A list of str values. Each str value must conform to the same restriction
      as a task name. Return list of str values.
    * A mixture of int ranges and int values. Return list of str values
      containing the sorted int list, zero-padded to the same width.

    Raise IllegalValueError if:
    * Mixing str and int range.
    * A str value breaks the task name restriction.
    """
    items = []
    can_only_be = None   # A flag to prevent mixing str and int range
    for item in _strip_and_unquote_list(keys, value):
        match = REC_PARAM_INT_RANGE.match(item)
        if match:
            if can_only_be == str:
                raise IllegalValueError(
                    'parameter', keys, value, 'mixing int range and str')
            can_only_be = int
            lower, upper, step = match.groups()
            if not step:
                step = 1
            items.extend(range(int(lower), int(upper) + 1, int(step)))
        elif TaskID.NAME_SUFFIX_REC.match(item):
            if not item.isdigit():
                if can_only_be == int:
                    raise IllegalValueError(
                        'parameter', keys, value, 'mixing int range and str')
                can_only_be = str
            items.append(item)
        else:
            raise IllegalValueError(
                'parameter', keys, value, '%s: bad value' % item)
    if not items or can_only_be == str or any(
            not str(item).isdigit() for item in items):
        return items
    else:
        return [int(item) for item in items]