#NEWLINE# def _parse_rfc( self , s ) : #NEWLINE# #INDENT# lines = s . splitlines ( ) #NEWLINE# if ( not lines ) : #NEWLINE# #INDENT# raise ValueError ( 'empty string' ) #NEWLINE# #UNINDENT# i = 0 #NEWLINE# while ( i < len ( lines ) ) : #NEWLINE# #INDENT# line = lines [ i ] . rstrip ( ) #NEWLINE# if ( not line ) : #NEWLINE# #INDENT# del lines [ i ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( i > 0 ) and ( line [ 0 ] == ' ' ) ) : #NEWLINE# #INDENT# lines [ ( i - 1 ) ] += line [ 1 : ] #NEWLINE# del lines [ i ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# i += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# tzid = None #NEWLINE# comps = [ ] #NEWLINE# invtz = False #NEWLINE# comptype = None #NEWLINE# for line in lines : #NEWLINE# #INDENT# if ( not line ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( name , value ) = line . split ( ':' , 1 ) #NEWLINE# parms = name . split ( ';' ) #NEWLINE# if ( not parms ) : #NEWLINE# #INDENT# raise ValueError ( 'empty property name' ) #NEWLINE# #UNINDENT# name = parms [ 0 ] . upper ( ) #NEWLINE# parms = parms [ 1 : ] #NEWLINE# if invtz : #NEWLINE# #INDENT# if ( name == 'BEGIN' ) : #NEWLINE# #INDENT# if ( value in ( 'STANDARD' , 'DAYLIGHT' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'unknown component: ' + value ) ) #NEWLINE# #UNINDENT# comptype = value #NEWLINE# founddtstart = False #NEWLINE# tzoffsetfrom = None #NEWLINE# tzoffsetto = None #NEWLINE# rrulelines = [ ] #NEWLINE# tzname = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'END' ) : #NEWLINE# #INDENT# if ( value == 'VTIMEZONE' ) : #NEWLINE# #INDENT# if comptype : #NEWLINE# #INDENT# raise ValueError ( ( 'component not closed: ' + comptype ) ) #NEWLINE# #UNINDENT# if ( not tzid ) : #NEWLINE# #INDENT# raise ValueError ( 'mandatory TZID not found' ) #NEWLINE# #UNINDENT# if ( not comps ) : #NEWLINE# #INDENT# raise ValueError ( 'at least one component is needed' ) #NEWLINE# #UNINDENT# self . _vtz [ tzid ] = _tzicalvtz ( tzid , comps ) #NEWLINE# invtz = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( value == comptype ) : #NEWLINE# #INDENT# if ( not founddtstart ) : #NEWLINE# #INDENT# raise ValueError ( 'mandatory DTSTART not found' ) #NEWLINE# #UNINDENT# if ( tzoffsetfrom is None ) : #NEWLINE# #INDENT# raise ValueError ( 'mandatory TZOFFSETFROM not found' ) #NEWLINE# #UNINDENT# if ( tzoffsetto is None ) : #NEWLINE# #INDENT# raise ValueError ( 'mandatory TZOFFSETFROM not found' ) #NEWLINE# #UNINDENT# rr = None #NEWLINE# if rrulelines : #NEWLINE# #INDENT# rr = rrule . rrulestr ( '\n' . join ( rrulelines ) , compatible = True , ignoretz = True , cache = True ) #NEWLINE# #UNINDENT# comp = _tzicalvtzcomp ( tzoffsetfrom , tzoffsetto , ( comptype == 'DAYLIGHT' ) , tzname , rr ) #NEWLINE# comps . append ( comp ) #NEWLINE# comptype = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'invalid component end: ' + value ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if comptype : #NEWLINE# #INDENT# if ( name == 'DTSTART' ) : #NEWLINE# #INDENT# rrulelines . append ( line ) #NEWLINE# founddtstart = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name in ( 'RRULE' , 'RDATE' , 'EXRULE' , 'EXDATE' ) ) : #NEWLINE# #INDENT# rrulelines . append ( line ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'TZOFFSETFROM' ) : #NEWLINE# #INDENT# if parms : #NEWLINE# #INDENT# raise ValueError ( ( 'unsupported %s parm: %s ' % ( name , parms [ 0 ] ) ) ) #NEWLINE# #UNINDENT# tzoffsetfrom = self . _parse_offset ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'TZOFFSETTO' ) : #NEWLINE# #INDENT# if parms : #NEWLINE# #INDENT# raise ValueError ( ( 'unsupported TZOFFSETTO parm: ' + parms [ 0 ] ) ) #NEWLINE# #UNINDENT# tzoffsetto = self . _parse_offset ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'TZNAME' ) : #NEWLINE# #INDENT# if parms : #NEWLINE# #INDENT# raise ValueError ( ( 'unsupported TZNAME parm: ' + parms [ 0 ] ) ) #NEWLINE# #UNINDENT# tzname = value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'COMMENT' ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'unsupported property: ' + name ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'TZID' ) : #NEWLINE# #INDENT# if parms : #NEWLINE# #INDENT# raise ValueError ( ( 'unsupported TZID parm: ' + parms [ 0 ] ) ) #NEWLINE# #UNINDENT# tzid = value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name in ( 'TZURL' , 'LAST-MODIFIED' , 'COMMENT' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'unsupported property: ' + name ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( name == 'BEGIN' ) and ( value == 'VTIMEZONE' ) ) : #NEWLINE# #INDENT# tzid = None #NEWLINE# comps = [ ] #NEWLINE# invtz = True