pymap.backend.dict

class pymap.backend.dict.DictBackend(login, config)[source]

Defines a backend that uses an in-memory dictionary for example usage and integration testing.

Parameters:
  • login (Login)

  • config (Config)

property login: Login

Login interface that handles authentication credentials.

property config: Config

The IMAP config in use by the backend.

property status: HealthStatus

The health status for the backend.

classmethod add_subparser(name, subparsers)[source]

Add a command-line argument sub-parser that will be used to choose this backend. For example:

parser = subparsers.add_parser('foo', help='foo backend')
parser.add_argument(...)
Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

async classmethod init(args, **overrides)[source]

Initialize the backend and return an instance.

Parameters:
  • args (Namespace) – The command-line arguments.

  • overrides (Any) – Override keyword arguments to the config constructor.

Return type:

tuple[DictBackend, Config]

async start(stack)[source]

Start the backend.

Parameters:

stack (AsyncExitStack) – An exit stack that should be used for cleanup.

Return type:

None

class pymap.backend.dict.Config(args, *, demo_data, demo_user, demo_password, demo_data_resource='pymap.backend.dict', admin_key=None, **extra)[source]

The config implementation for the dict backend.

Parameters:
  • args (Namespace)

  • demo_data (bool)

  • demo_user (str)

  • demo_password (str)

  • demo_data_resource (str)

  • admin_key (bytes | None)

  • extra (Any)

property backend_capability: BackendCapability

Allows backends to declare support for IMAP extensions and other capabilities.

property demo_data: bool

True if demo data should be loaded at startup.

property demo_data_resource: str

Resource path of demo data files.

property demo_user: str

A login name that is valid at startup, which defaults to demouser.

property demo_password: str

The password for the demo_user login name, which defaults to demopass.

classmethod parse_args(args)[source]

Given command-line arguments, return a dictionary of keywords that should be passed in to the IMAPConfig (or sub-class) constructor. Sub-classes should override this method as needed.

Parameters:

args (Namespace) – The arguments parsed from the command-line.

Return type:

Mapping[str, Any]