(obj)
Turn obj.value into a timedelta or datetime.
Turn obj.value into a timedelta or datetime.
Turn obj . value into a timedelta or datetime .
def transformToNative(obj):
        """
        Turn obj.value into a timedelta or datetime.
        """
        if obj.isNative:
            return obj
        value = getattr(obj, 'value_param', 'DURATION').upper()
        if hasattr(obj, 'value_param'):
            del obj.value_param
        if obj.value == '':
            obj.isNative = True
            return obj
        elif value == 'DURATION':
            try:
                return Duration.transformToNative(obj)
            except ParseError:
                logger.warning("TRIGGER not recognized as DURATION, trying "
                               "DATE-TIME, because iCal sometimes exports "
                               "DATE-TIMEs without setting VALUE=DATE-TIME")
                try:
                    obj.isNative = False
                    dt = DateTimeBehavior.transformToNative(obj)
                    return dt
                except:
                    msg = "TRIGGER with no VALUE not recognized as DURATION " \
                          "or as DATE-TIME"
                    raise ParseError(msg)
        elif value == 'DATE-TIME':
            # TRIGGERs with DATE-TIME values must be in UTC, we could validate
            # that fact, for now we take it on faith.
            return DateTimeBehavior.transformToNative(obj)
        else:
            raise ParseError("VALUE must be DURATION or DATE-TIME")
def transformToNative ( obj ) : if obj . isNative : return obj value = getattr ( obj , 'value_param' , 'DURATION' ) . upper ( ) if hasattr ( obj , 'value_param' ) : del obj . value_param if obj . value == '' : obj . isNative = True return obj elif value == 'DURATION' : try : return Duration . transformToNative ( obj ) except ParseError : logger . warning ( "TRIGGER not recognized as DURATION, trying " "DATE-TIME, because iCal sometimes exports " "DATE-TIMEs without setting VALUE=DATE-TIME" ) try : obj . isNative = False dt = DateTimeBehavior . transformToNative ( obj ) return dt except : msg = "TRIGGER with no VALUE not recognized as DURATION " "or as DATE-TIME" raise ParseError ( msg ) elif value == 'DATE-TIME' : # TRIGGERs with DATE-TIME values must be in UTC, we could validate # that fact, for now we take it on faith. return DateTimeBehavior . transformToNative ( obj ) else : raise ParseError ( "VALUE must be DURATION or DATE-TIME" )