示例#1
0
def _fields_tuple_from_dict(fields, field_partials=field.partials, field_default=field.DEFAULT_VALUE):
    """
    Convert the given expression dict to an "ordered" tuple.

    The "order" of values within the tuple matches the field ordering of the expression e.g. "second" is first
     and "year" is last.

    :param fields: Dict containing field names -> values.
    :param field_partials: (Optional) Mapping of field names -> partials that create :class:`~crython.field.CronField`.
    :param field_default: (Optional) Default value of a field if one is not set.
    :return: An "ordered" tuple of :class:`~crython.field.CronField` instances.
    """
    return tuple(partial(fields.get(name, field_default)) for (name, partial) in compat.iteritems(field_partials))
示例#2
0
def _fields_tuple_from_dict(fields,
                            field_partials=field.partials,
                            field_default=field.DEFAULT_VALUE):
    """
    Convert the given expression dict to an "ordered" tuple.

    The "order" of values within the tuple matches the field ordering of the expression e.g. "second" is first
     and "year" is last.

    :param fields: Dict containing field names -> values.
    :param field_partials: (Optional) Mapping of field names -> partials that create :class:`~crython.field.CronField`.
    :param field_default: (Optional) Default value of a field if one is not set.
    :return: An "ordered" tuple of :class:`~crython.field.CronField` instances.
    """
    return tuple(
        partial(fields.get(name, field_default))
        for (name, partial) in compat.iteritems(field_partials))
示例#3
0
文件: field.py 项目: ahawker/crython
#: Full day of week names e.g 'Monday', 'Tuesday', 'Wednesday'.
DAY_NAMES = dict((v.lower(), k) for k, v in enumerate(calendar.day_name))

#: Abbreviated day of week names e.g. 'Mon', 'Tue', 'Wed'.
DAY_ABBRS = dict((v.lower(), k) for k, v in enumerate(calendar.day_abbr))

#: Full month names e.g. 'January', 'February', 'March'.
MONTH_NAMES = dict((v.lower(), k) for k, v in enumerate(calendar.month_name))

#: Abbreviated month names e.g. 'Jan', 'Feb', 'Mar'.
MONTH_ABBRS = dict((v.lower(), k) for k, v in enumerate(calendar.month_abbr))

#: English words (full and abbreviated) for day of week & month names that are possible values.
PHRASES = dict((k.lower(), v)
               for d in (DAY_NAMES, DAY_ABBRS, MONTH_NAMES, MONTH_ABBRS)
               for (k, v) in compat.iteritems(d) if k)

#: Regex for detecting valid english words for day of week & month names.
PHRASES_REGEX = re.compile('|'.join(PHRASES.keys()).lstrip('|'), flags=re.IGNORECASE)

#: Regex for detecting "range" and "step" characters e.g. "1-10/2".
RANGE_REGEX = re.compile(r'[-/]', flags=re.IGNORECASE)

#: Default value for field that does not have one specified.
DEFAULT_VALUE = '*'

#: Name for the "second" field in an expression; first value.
SECOND_NAME = 'second'

#: Name for the "minute" field in an expression; second value.
MINUTE_NAME = 'minute'
示例#4
0
#: Full day of week names e.g 'Monday', 'Tuesday', 'Wednesday'.
DAY_NAMES = dict((v.lower(), k) for k, v in enumerate(calendar.day_name))

#: Abbreviated day of week names e.g. 'Mon', 'Tue', 'Wed'.
DAY_ABBRS = dict((v.lower(), k) for k, v in enumerate(calendar.day_abbr))

#: Full month names e.g. 'January', 'February', 'March'.
MONTH_NAMES = dict((v.lower(), k) for k, v in enumerate(calendar.month_name))

#: Abbreviated month names e.g. 'Jan', 'Feb', 'Mar'.
MONTH_ABBRS = dict((v.lower(), k) for k, v in enumerate(calendar.month_abbr))

#: English words (full and abbreviated) for day of week & month names that are possible values.
PHRASES = dict((k.lower(), v)
               for d in (DAY_NAMES, DAY_ABBRS, MONTH_NAMES, MONTH_ABBRS)
               for (k, v) in compat.iteritems(d) if k)

#: Regex for detecting valid english words for day of week & month names.
PHRASES_REGEX = re.compile('|'.join(PHRASES.keys()).lstrip('|'),
                           flags=re.IGNORECASE)

#: Regex for detecting "range" and "step" characters e.g. "1-10/2".
RANGE_REGEX = re.compile(r'[-/]', flags=re.IGNORECASE)

#: Default value for field that does not have one specified.
DEFAULT_VALUE = '*'

#: Name for the "second" field in an expression; first value.
SECOND_NAME = 'second'

#: Name for the "minute" field in an expression; second value.