How to use the icalendar.parser_tools.to_unicode 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 / parser.py View on Github external
"""Turn a parts into a content line.
        """
        assert isinstance(params, Parameters)
        if hasattr(values, 'to_ical'):
            values = values.to_ical()
        else:
            values = vText(values).to_ical()
        # elif isinstance(values, basestring):
        #    values = escape_char(values)

        # TODO: after unicode only, remove this
        # Convert back to unicode, after to_ical encoded it.
        name = to_unicode(name)
        values = to_unicode(values)
        if params:
            params = to_unicode(params.to_ical(sorted=sorted))
            return cls('%s;%s:%s' % (name, params, values))
        return cls('%s:%s' % (name, values))
github collective / icalendar / src / icalendar / caselessdict.py View on Github external
def pop(self, key, default=None):
        key = to_unicode(key)
        return super(CaselessDict, self).pop(key.upper(), default)
github collective / icalendar / src / icalendar / caselessdict.py View on Github external
def has_key(self, key):
        key = to_unicode(key)
        return super(CaselessDict, self).__contains__(key.upper())
github collective / icalendar / src / icalendar / caselessdict.py View on Github external
def get(self, key, default=None):
        key = to_unicode(key)
        return super(CaselessDict, self).get(key.upper(), default)
github collective / icalendar / src / icalendar / parser.py View on Github external
    @classmethod
    def from_parts(cls, name, params, values, sorted=True):
        """Turn a parts into a content line.
        """
        assert isinstance(params, Parameters)
        if hasattr(values, 'to_ical'):
            values = values.to_ical()
        else:
            values = vText(values).to_ical()
        # elif isinstance(values, basestring):
        #    values = escape_char(values)

        # TODO: after unicode only, remove this
        # Convert back to unicode, after to_ical encoded it.
        name = to_unicode(name)
        values = to_unicode(values)
        if params:
            params = to_unicode(params.to_ical(sorted=sorted))
            return cls('%s;%s:%s' % (name, params, values))
        return cls('%s:%s' % (name, values))
github collective / icalendar / src / icalendar / tools.py View on Github external
def uid(self, host_name='example.com', unique=''):
        """Generates a unique id consisting of:
            datetime-uniquevalue@host.
        Like:
            20050105T225746Z-HKtJMqUgdO0jDUwm@example.com
        """
        host_name = to_unicode(host_name)
        unique = unique or self.rnd_string()
        today = to_unicode(vDatetime(datetime.today()).to_ical())
        return vText('%s-%s@%s' % (today,
                                   unique,
                                   host_name))
github collective / icalendar / src / icalendar / parser.py View on Github external
    @classmethod
    def from_parts(cls, name, params, values, sorted=True):
        """Turn a parts into a content line.
        """
        assert isinstance(params, Parameters)
        if hasattr(values, 'to_ical'):
            values = values.to_ical()
        else:
            values = vText(values).to_ical()
        # elif isinstance(values, basestring):
        #    values = escape_char(values)

        # TODO: after unicode only, remove this
        # Convert back to unicode, after to_ical encoded it.
        name = to_unicode(name)
        values = to_unicode(values)
        if params:
            params = to_unicode(params.to_ical(sorted=sorted))
            return cls('%s;%s:%s' % (name, params, values))
        return cls('%s:%s' % (name, values))
github collective / icalendar / src / icalendar / parser.py View on Github external
def __new__(cls, value, strict=False, encoding=DEFAULT_ENCODING):
        value = to_unicode(value, encoding=encoding)
        assert '\n' not in value, ('Content line can not contain unescaped '
                                    'new line characters.')
        self = super(Contentline, cls).__new__(cls, value)
        self.strict = strict
        return self
github collective / icalendar / src / icalendar / caselessdict.py View on Github external
def __init__(self, *args, **kwargs):
        """Set keys to upper for initial dict.
        """
        super(CaselessDict, self).__init__(*args, **kwargs)
        for key, value in self.items():
            key_upper = to_unicode(key).upper()
            if key != key_upper:
                super(CaselessDict, self).__delitem__(key)
                self[key_upper] = value
github collective / icalendar / src / icalendar / tools.py View on Github external
def uid(self, host_name='example.com', unique=''):
        """Generates a unique id consisting of:
            datetime-uniquevalue@host.
        Like:
            20050105T225746Z-HKtJMqUgdO0jDUwm@example.com
        """
        host_name = to_unicode(host_name)
        unique = unique or self.rnd_string()
        today = to_unicode(vDatetime(datetime.today()).to_ical())
        return vText('%s-%s@%s' % (today,
                                   unique,
                                   host_name))