How to use the imapclient.util.to_unicode function in IMAPClient

To help you get started, we’ve selected a few IMAPClient 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 mjs / imapclient / imapclient / imapclient.py View on Github external
The IMAP server responds with the quota root and the quotas associated
        so there is usually no need to call `get_quota` after.

        See :rfc:`2087` for more details.

        Return a tuple of MailboxQuotaRoots and list of Quota associated
        """
        quota_root_rep = self._raw_command_untagged(
            b'GETQUOTAROOT', to_bytes(mailbox), uid=False,
            response_name='QUOTAROOT'
        )
        quota_rep = pop_with_default(self._imap.untagged_responses, 'QUOTA', [])
        quota_root_rep = parse_response(quota_root_rep)
        quota_root = MailboxQuotaRoots(
            to_unicode(quota_root_rep[0]),
            [to_unicode(q) for q in quota_root_rep[1:]]
        )
        return quota_root, _parse_quota(quota_rep)
github mjs / imapclient / imapclient / imapclient.py View on Github external
def _raw_command_untagged(self, command, args, response_name=None, unpack=False, uid=True):
        # TODO: eventually this should replace _command_and_check (call it _command)
        typ, data = self._raw_command(command, args, uid=uid)
        if response_name is None:
            response_name = command
        typ, data = self._imap._untagged_response(typ, data, to_unicode(response_name))
        self._checkok(to_unicode(command), typ, data)
        if unpack:
            return data[0]
        return data
github mjs / imapclient / imapclient / imapclient.py View on Github external
def _raw_command_untagged(self, command, args, response_name=None, unpack=False, uid=True):
        # TODO: eventually this should replace _command_and_check (call it _command)
        typ, data = self._raw_command(command, args, uid=uid)
        if response_name is None:
            response_name = command
        typ, data = self._imap._untagged_response(typ, data, to_unicode(response_name))
        self._checkok(to_unicode(command), typ, data)
        if unpack:
            return data[0]
        return data
github mjs / imapclient / imapclient / imapclient.py View on Github external
def login(self, username, password):
        """Login using *username* and *password*, returning the
        server response.
        """
        try:
            rv = self._command_and_check(
                'login',
                to_unicode(username),
                to_unicode(password),
                unpack=True,
            )
        except exceptions.IMAPClientError as e:
            raise exceptions.LoginError(str(e))

        logger.info('Logged in as %s', username)
        return rv
github mjs / imapclient / imapclient / imapclient.py View on Github external
def _parse_quota(quota_rep):
    quota_rep = parse_response(quota_rep)
    rv = list()
    for quota_root, quota_resource_infos in as_pairs(quota_rep):
        for quota_resource_info in as_triplets(quota_resource_infos):
            rv.append(Quota(
                quota_root=to_unicode(quota_root),
                resource=to_unicode(quota_resource_info[0]),
                usage=quota_resource_info[1],
                limit=quota_resource_info[2]
            ))
    return rv