How to use the icalendar.parser.Parameters function in icalendar

To help you get started, we’ve selected a few icalendar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github collective / icalendar / src / icalendar / prop.py View on Github external
def __init__(self, obj):
        self.obj = to_unicode(obj)
        self.params = Parameters(encoding='BASE64', value="BINARY")
github collective / icalendar / src / icalendar / prop.py View on Github external
def __init__(self, dt):
        if not isinstance(dt, (datetime, date, timedelta, time, tuple)):
            raise ValueError('You must use datetime, date, timedelta, '
                             'time or tuple (for periods)')
        if isinstance(dt, datetime):
            self.params = Parameters({'value': 'DATE-TIME'})
        elif isinstance(dt, date):
            self.params = Parameters({'value': 'DATE'})
        elif isinstance(dt, time):
            self.params = Parameters({'value': 'TIME'})
        elif isinstance(dt, tuple):
            self.params = Parameters({'value': 'PERIOD'})

        if (isinstance(dt, datetime) or isinstance(dt, time))\
                and getattr(dt, 'tzinfo', False):
            tzinfo = dt.tzinfo
            if tzinfo is not pytz.utc and\
               (tzutc is None or not isinstance(tzinfo, tzutc)):
                # set the timezone as a parameter to the property
                tzid = tzid_from_dt(dt)
                if tzid:
                    self.params.update({'TZID': tzid})
        self.dt = dt
github collective / icalendar / src / icalendar / prop.py View on Github external
def __init__(self, *args, **kwargs):
        super(vRecur, self).__init__(*args, **kwargs)
        self.params = Parameters()
github collective / icalendar / src / icalendar / cal.py View on Github external
def content_line(self, name, value, sorted=True):
        """Returns property as content line.
        """
        params = getattr(value, 'params', Parameters())
        return Contentline.from_parts(name, params, value, sorted=sorted)
github learning-unlimited / ESP-Website / esp / esp / lib / iCalendar-0.11 / src / icalendar / cal.py View on Github external
def content_lines(self):
        "Converts the Component and subcomponents into content lines"
        contentlines = Contentlines()
        for name, values in self.property_items():
            params = getattr(values, 'params', Parameters())
            contentlines.append(Contentline.from_parts((name, params, values)))
        contentlines.append('') # remember the empty string in the end
        return contentlines
github collective / icalendar / src / icalendar / cal.py View on Github external
icalendar's own property types (Fallback is "vText")
                       or False, if not.
        :type encode: Boolean

        :returns: icalendar property value
        """
        if not encode:
            return value
        if isinstance(value, types_factory.all_types):
            # Don't encode already encoded values.
            return value
        klass = types_factory.for_property(name)
        obj = klass(value)
        if parameters:
            if isinstance(parameters, dict):
                params = Parameters()
                for key, item in parameters.items():
                    params[key] = item
                parameters = params
            assert isinstance(parameters, Parameters)
            obj.params = parameters
        return obj
github orbekk / erebus / erebusconv.py View on Github external
cnode: typically from Erebus2ICSVisitor
    return: icalendar.Calendar
    """
    comp = Component()
    comp.name = cnode.name.upper()

    for k,v in cnode.attr.iteritems():
        # If an attribute is a CNode, say n, we must add all the
        # attributes of n as parameters to the iCalendar element. We
        # first encode the value to the corresponding iCalendar value
        # (with types_factory, like icalendar.Component does
        # internally), and then add the parameters.
        if v.__class__ == CNode:
            target_class = types_factory.for_property(k)
            val = target_class(v.content)
            val.params = Parameters()
            for p,pv in v.attr.iteritems():
                val.params[p] = pv

            comp.add(k, val, encode=0)
        else:
            comp.add(k, v, encode=1)

    for c in cnode.children:
        comp.add_component(cnode2ical(c))

    return comp
github entu / entu / appengine / icalendar / cal.py View on Github external
def content_lines(self):
        "Converts the Component and subcomponents into content lines"
        contentlines = Contentlines()
        for name, values in self.property_items():
            params = getattr(values, 'params', Parameters())
            contentlines.append(Contentline.from_parts((name, params, values)))
        contentlines.append('') # remember the empty string in the end
        return contentlines