Example #1
0
 def __str__(self):
     if self.is_reboot:
         return REBOOT_KEYWORD
     return ' '.join(
         compat.str(f)
         for f in (self.second, self.minute, self.hour, self.day,
                   self.month, self.weekday, self.year))
Example #2
0
def test_cron_expression_new_with_no_params_returns_default():
    """
    Assert that :meth:`~crython.expression.CronExpression.new` returns a :class:`~crython.expression.CronExpression`
    of the default expression value when not given any parameters.
    """
    expr = expression.CronExpression.new()
    assert compat.str(expr) == expression.DEFAULT_VALUE
Example #3
0
def test_cron_expression_new_with_no_params_returns_default():
    """
    Assert that :meth:`~crython.expression.CronExpression.new` returns a :class:`~crython.expression.CronExpression`
    of the default expression value when not given any parameters.
    """
    expr = expression.CronExpression.new()
    assert compat.str(expr) == expression.DEFAULT_VALUE
Example #4
0
def test_cron_expression_new_handles_reserved_keywords(reserved_keywords):
    """
    Assert that :meth:`~crython.expression.CronExpression.new` returns a :class:`~crython.expression.CronExpression`
    that maps to the correct space-delimited value for a given reserved keyword.
    """
    keyword, value = reserved_keywords
    expr = expression.CronExpression.new(keyword)
    assert compat.str(expr) == expression.RESERVED_KEYWORDS[keyword]
Example #5
0
def test_cron_expression_new_handles_reserved_keywords(reserved_keywords):
    """
    Assert that :meth:`~crython.expression.CronExpression.new` returns a :class:`~crython.expression.CronExpression`
    that maps to the correct space-delimited value for a given reserved keyword.
    """
    keyword, value = reserved_keywords
    expr = expression.CronExpression.new(keyword)
    assert compat.str(expr) == expression.RESERVED_KEYWORDS[keyword]
Example #6
0
def _phrase_to_numeral(phrase, phrases=PHRASES, regex=PHRASES_REGEX):
    """
    Replace any full or abbreviated english dow/mon phrases (Jan, Monday, etc) from the field value
    with its respective integer value as a string.

    :param phrase: English word to convert to integer
    :param phrases: (Optional) Mapping of english word to integer value; Default: PHRASES
    :param regex: (Optional) Mapping of english word to integer value; Default: PHRASES_REGEX
    :return: String representation of integer value of the given english word
    """
    def _repl(match):
        return compat.str(phrases[match.group(0).lower()])

    return regex.sub(_repl, compat.str(phrase))
Example #7
0
def _phrase_to_numeral(phrase, phrases=PHRASES, regex=PHRASES_REGEX):
    """
    Replace any full or abbreviated english dow/mon phrases (Jan, Monday, etc) from the field value
    with its respective integer value as a string.

    :param phrase: English word to convert to integer
    :param phrases: (Optional) Mapping of english word to integer value; Default: PHRASES
    :param regex: (Optional) Mapping of english word to integer value; Default: PHRASES_REGEX
    :return: String representation of integer value of the given english word
    """
    def _repl(match):
        return compat.str(phrases[match.group(0).lower()])

    return regex.sub(_repl, compat.str(phrase))
Example #8
0
 def __repr__(self):
     return '<{0}({1})>'.format(self.__class__.__name__, compat.str(self))
Example #9
0
 def __str__(self):
     return compat.str(self.value)
Example #10
0
 def _repl(match):
     return compat.str(phrases[match.group(0).lower()])
Example #11
0
 def __str__(self):
     return compat.str(self.value)
Example #12
0
 def _repl(match):
     return compat.str(phrases[match.group(0).lower()])
Example #13
0
 def __str__(self):
     if self.is_reboot:
         return REBOOT_KEYWORD
     return ' '.join(compat.str(f) for f in (self.second, self.minute, self.hour, self.day,
                                             self.month, self.weekday, self.year))
Example #14
0
 def __repr__(self):
     return '<{0}({1})>'.format(self.__class__.__name__, compat.str(self))
Example #15
0
def second_field_valid_numeral_as_str(second_valid_numeral):
    """
    Fixture that yields back a :class:`~crython.field.CronField` for the "second" field created
    with a valid numeral as a string.
    """
    return field.second(compat.str(second_valid_numeral))
Example #16
0
def second_field_valid_numeral_as_str(second_valid_numeral):
    """
    Fixture that yields back a :class:`~crython.field.CronField` for the "second" field created
    with a valid numeral as a string.
    """
    return field.second(compat.str(second_valid_numeral))