in source/code/scheduling/setbuilder.py [0:0]
def __init__(self, names=None, min_value=None, max_value=None, offset=None, wrap=False,
ignore_case=True, significant_name_characters=None,
first_item_wildcard=WILDCARD_FIRST,
all_items_wildcards=WILDCARD_ALL,
last_item_wildcard=WILDCARD_LAST):
"""
:param names: Names for values
:param min_value: Value for first item in set created from min and max value
:param max_value: Max value for value in set created from min and max value
:param offset: Offset for first value in set created from names
:param wrap: Set to True to let sets wrap at max value
:param ignore_case: Set to True to ignore case when mapping values from their names
:param significant_name_characters: Number of significant characters to use when mapping values from their names
:param first_item_wildcard: First item wildcard
:param all_items_wildcards: All Items wildcard
:param last_item_wildcard: Last item wildcard
"""
# use value names to setup builder
if names is not None:
# min-value and max_value are not allowed
if min_value is not None or max_value is not None:
raise ValueError("min_value and max_value parameters can not be used with names parameter")
# names to display for values
self._display_names = [str(i) for i in names]
# names to identify values, use only the specified number of significant characters
self._names = names if significant_name_characters == 0 else [name[0:significant_name_characters] for name in names]
# convert to lowercase if case is ignored
if ignore_case:
self._names = [name.lower() for name in self._names]
# offset for values
self._offset = offset if offset else 0
self._min_value = self._offset
self._max_value = len(names) - 1 + self._offset
# build list to identify values by their numeric string value
self._values = self.values = [str(i + self._offset) for i in range(0, len(self._names))]
else:
# setup builder with min and max values instead if names
# both must be present
if min_value is None or max_value is None:
raise ValueError("min_value or max_value may not be None if names parameter is None")
# min must be less or equal than max
if min_value > max_value:
raise ValueError("min_value parameter should be less or equal to max_value parameter")
# build names to identify values
self._names = [str(i) for i in range(min_value, max_value + 1)]
self._min_value = min_value
self._max_value = max_value
self._values = self._names
# names used for display
self._display_names = self._values
# offset may not conflict with min value
if offset is not None and offset != min_value:
raise ValueError("offset parameter should not be used or have the same value as min_value")
self._offset = min_value
self._logging = logging.getLogger("SetBuilder")
self._wrap = wrap
self._ignore_case = ignore_case
self._all_items_wildcard_characters = all_items_wildcards
self._first_item_wildcard = first_item_wildcard
self._last_item_wildcard_character = last_item_wildcard
self._significant_name_characters = significant_name_characters \
if names is not None and significant_name_characters is not None else 0
# custom parsers to be executed before standard parsers
self._pre_custom_parsers = []
# custom parsers to be executes after standard parsers
self._post_custom_parsers = []
# setup list of standard parsers
self._standard_parsers = [
self._parse_name, # name
self._parse_value, # value, first and last wildcard
self._parse_name_range, # name-name
self._parse_value_range, # value-value
self._parse_all, # all items wildcard
self._parse_name_incr, # name/incr
self._parse_value_incr, # value/incr
self._parse_name_range_incr, # name-name/incr
self._parse_value_range_incr] # value-value/incr