Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get mailboxes? #102

Open
bahkadomos opened this issue Mar 16, 2024 · 1 comment
Open

How to get mailboxes? #102

bahkadomos opened this issue Mar 16, 2024 · 1 comment

Comments

@bahkadomos
Copy link

bahkadomos commented Mar 16, 2024

Hello. I'm trying to get mail folders with list() method.

resp = await client.list('""', '^.*$')
>>> Response(result='OK', lines=[b'List completed (0.002 + 0.000 + 0.001 secs).'])

But I don't see anything other than "List completed". The second argument has annotation Pattern. But if I pass it as re.compile('.*') it raises an error in __repr__:

This is a method from the aioimaplib:

async def list(self, reference_name: str, mailbox_pattern: Pattern) -> Response:
        return await asyncio.wait_for(self.protocol.simple_command('LIST', reference_name, mailbox_pattern), self.timeout)

And this is a sample of my code:

resp = await client.list('""', re.compile('.*'))

This is an exception:

File "\.venv\Lib\site-packages\aioimaplib\aioimaplib.py", line 166, in __repr__
    space=' ' if self.args else '', args=' '.join(self.args))

I also tried to comment out __repr__. After that the script runs endlessly and nothing happens.

My question - what is the correct way to get folders?

@mobyw
Copy link

mobyw commented Nov 5, 2024

resp = await client.list('""', "*")

mailbox_pattern type annotation is incorrect here. parameters of simple_commands can only be str

try following equivalent code if u donnot want an type checking error msg:

await asyncio.wait_for(
    client.protocol.execute(
        aioimaplib.Command(
            "LIST", client.protocol.new_tag(), '""', '"*"'
        )
    ),
    client.timeout,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants