import os
import re
+import pprint
from nagios.object.verify import NagiosVerifyError, NagiosObjectVerifier
returns a key/value pair on success,
returns None on failure"""
+ for key in ( 'timeperiod_name', 'alias', 'exclude', 'name', 'register', 'use' ):
+ match = re.match( r'^' + key + r'\s+', line )
+ if match is not None:
+ return None
+
+ re_time = r'(?:(?:(?:[01][0-9]|2[0-3]):[0-5][0-9])|24:00)'
+ re_timerange = re_time + r'\s*-\s*' + re_time
+ re_timeranges = r'(' + re_timerange + r')(?:,(' + re_timerange + r'))*'
+ re_weekdays = r'(monday|tuesday|wednesday|thursday|friday|saturday|sunday)'
+
+ regex = r'^' + re_weekdays + r'\s+' + re_timeranges + r'$'
+ #self.logger.debug( "Timeperiod Regex {0!r}.\n\t{1!r}".format( regex, line ) )
+
+ match = re.search( regex, line )
+ if match is not None:
+
+ pp = pprint.PrettyPrinter( indent = 4, depth = 6, width = 120 )
+ key = match.group(1)
+ value = []
+ for v in match.groups()[1:-1]:
+ value.append(v)
+ return ( key, value )
+
# Currently only a stub
return None