Esempio n. 1
0
    def __init__(self, arg, name="DTSTART", zone=None):
        """ 
        Create a new Time from a string or number of seconds past the 
        POSIX epoch

        Time("19970325T123000Z")  Construct from an iCalendar string
        Time(8349873494)          Construct from seconds past POSIX epoch
        
        """
        e1 = icalerror_supress("MALFORMEDDATA")
        e2 = icalerror_supress("BADARG")

        if isinstance(arg, DictType):
            # Dictionary -- used for creating from Component
            self.tt = icaltime_from_string(arg['value'])
            Property.__init__(self, ref=arg['ref'])
        else:
            if isinstance(arg, StringType):
                # Create from an iCal string
                self.tt = icaltime_from_string(arg)
            elif isinstance(arg, IntType) or   \
                 isinstance(arg, FloatType):
                # Create from seconds past the POSIX epoch
                if zone:
                    self.tt = icaltime_from_timet_with_zone(
                        int(arg), 0, icaltimezone_get_builtin_timezone(zone))
                else:
                    self.tt = icaltime_from_timet_with_zone(
                        int(arg), 0, icaltimezone_get_utc_timezone())
            elif isinstance(arg, Time):
                # Copy an instance
                self.tt = arg.tt
            else:
                self.tt = icaltime_null_time()

            Property.__init__(self, type=name)

        icalerror_restore("MALFORMEDDATA", e1)
        icalerror_restore("BADARG", e2)

        if icaltime_is_null_time(self.tt):
            raise Property.ConstructorFailedError("Failed to construct a Time")

        try:
            self._update_value()
        except Property.UpdateFailedError:
            raise Property.ConstructorFailedError("Failed to construct a Time")
Esempio n. 2
0
    def __init__(self,arg,name='FREEBUSY'):
        """ """

        Property.__init__(self, type = name)

        self.pt=None
        
        #icalerror_clear_errno()
        e1=icalerror_supress("MALFORMEDDATA")
        e2=icalerror_supress("BADARG")

        if isinstance(arg, DictType):
            

            es=icalerror_supress("MALFORMEDDATA")
            self.pt = icalperiodtype_from_string(arg['value'])
            icalerror_restore("MALFORMEDDATA",es)

            Property.__init__(self, ref=arg['ref'])
        else:
            if isinstance(arg, StringType):

                self.pt = icalperiodtype_from_string(arg)

            else:
                self.pt = icalperiodtype_null_period()

            Property.__init__(self,type=name)
                
        icalerror_restore("MALFORMEDDATA",e1)
        icalerror_restore("BADARG",e2)


        if self.pt == None or icalperiodtype_is_null_period(self.pt):
            raise Property.ConstructorFailedError("Failed to construct Period")

        
        try:
            self._update_value()
        except Property.UpdateFailedError:
            raise Property.ConstructorFailedError("Failed to construct Period")
Esempio n. 3
0
def Trigger(arg):        
    class Trigger_Time(Time): 
        def __init__(self,arg): Time.__init__(self,arg,"TRIGGER")
    
    class Trigger_Duration(Duration):
        def __init__(self,arg): Duration.__init__(self,arg,"TRIGGER")

    p = None
    for c in [Trigger_Duration, Trigger_Time]:
        try: return c(arg)
        except Property.ConstructorFailedError, d: pass        
    raise Property.ConstructorFailedError("Failed to construct TRIGGER from "+str(arg))
Esempio n. 4
0
    def __init__(self, arg, name="DURATION"):
        """
        Create a new duration from an RFC2445 string or number of seconds.
        Construct the duration from an iCalendar string or a number of seconds.

        Duration("P3DT2H34M45S")   Construct from an iCalendar string
        Duration(3660)             Construct from seconds
        """

        self.dur = None

        e = icalerror_supress("MALFORMEDDATA")

        if isinstance(arg, DictType):

            self.dur = icaldurationtype_from_string(arg['value'])
            Property.__init__(self, ref=arg['ref'])
        else:
            if isinstance(arg, StringType):
                self.dur = icaldurationtype_from_string(arg)
            elif isinstance(arg, IntType):
                self.dur = icaldurationtype_from_int(arg)
            elif isinstance(arg, Duration):
                self.dur = arg.dur
            else:
                self.dur = icaldurationtype_null_duration()

            Property.__init__(self, type=name)

        icalerror_restore("MALFORMEDDATA", e)

        if self.dur == None or icaldurationtype_is_null_duration(self.dur):
            raise Property.ConstructorFailedError(
                "Failed to construct Duration from " + str(arg))

        try:
            self._update_value()
        except Property.UpdateFailedError:
            raise Property.ConstructorFailedError(
                "Failed to construct Duration from  " + str(arg))
Esempio n. 5
0
def RDate(arg):

    class RDate_Time(Time):
        def __init__(self,arg): Time.__init__(self,arg,"RDATE")
    
    class RDate_Period(Period):
        def __init__(self,arg): Period.__init__(self,arg,"RDATE")

    p = None
    for c in [RDate_Time, RDate_Period]:
        try: return c(arg)
        except Property.ConstructorFailedError, d: pass
    raise Property.ConstructorFailedError("Failed to construct RDATE from "+str(arg))
def RDate(arg):
    class RDate_Time(Time):
        def __init__(self, arg):
            Time.__init__(self, arg, "RDATE")

    class RDate_Period(Period):
        def __init__(self, arg):
            Period.__init__(self, arg, "RDATE")

    p = None
    for c in [RDate_Time, RDate_Period]:
        try:
            return c(arg)
        except Property.ConstructorFailedError, d:
            pass
    raise Property.ConstructorFailedError("Failed to construct RDATE from " +
                                          str(arg))


def Trigger(arg):
    class Trigger_Time(Time):
        def __init__(self, arg):
            Time.__init__(self, arg, "TRIGGER")

    class Trigger_Duration(Duration):
        def __init__(self, arg):
            Duration.__init__(self, arg, "TRIGGER")

    p = None
    for c in [Trigger_Duration, Trigger_Time]:
        try:
            return c(arg)
Esempio n. 7
0
#!/usr/bin/env python 
Esempio n. 8
0
#!/usr/bin/env python 
Esempio n. 9
0
#!/usr/bin/env python