noc.core.timepattern

Module Contents

noc.core.timepattern.RC
noc.core.timepattern.DoW = ['mon', 'tue', 'wen', 'thu', 'fri', 'sat', 'sun']
noc.core.timepattern.DoWRE
noc.core.timepattern.DAY_PATTERNS = [None, None, None, None, None, None, None, None]
noc.core.timepattern.TIME_PATTERNS = [None, None]
class noc.core.timepattern.TimePattern(pattern)

Bases: object

>>> import datetime
>>> TimePattern("13").match(datetime.datetime(year=2005,month=3,day=13))
True
>>> TimePattern("02").match(datetime.datetime(year=2005,month=3,day=13))
False
>>> TimePattern("01-15").match(datetime.datetime(year=2005,month=3,day=13))
True
>>> TimePattern("01.03").match(datetime.datetime(year=2005,month=3,day=13))
False
>>> TimePattern("13.03").match(datetime.datetime(year=2005,month=3,day=13))
True
>>> TimePattern("01.03-02.04").match(datetime.datetime(year=2005,month=3,day=13))
True
>>> TimePattern("13.03.2005").match(datetime.datetime(year=2005,month=3,day=13))
True
>>> TimePattern("01.03.2005-15.03.2005").match(datetime.datetime(year=2005,month=3,day=13))
True
>>> TimePattern("sun").match(datetime.datetime(year=2005,month=3,day=13))
True
>>> TimePattern("fri").match(datetime.datetime(year=2005,month=3,day=13))
False
>>> TimePattern("fri-sun").match(datetime.datetime(year=2005,month=3,day=13))
True
>>> TimePattern("zho")
Traceback (most recent call last):
...
SyntaxError: Invalid expression 'zho'
>>> TimePattern(None).match(datetime.datetime(year=2005,month=3,day=13))
True
match(self, d)

Check datetime object matches time pattern :param d: :return: Boolean result

classmethod compile_to_python(cls, tp)

Convert a string of a list of time pattern declarations to the python expression :param tp: :return:

class noc.core.timepattern.TimePatternList(patterns)

Bases: object

Enclosure for a list of time patterns

match(self, d)