# Path: modoboa_imap_migration/modo_extension.py
# class ImapMigration(ModoExtension):
#     """The ImapMigration extension class."""
# 
#     name = "modoboa_imap_migration"
#     label = ugettext_lazy("IMAP migration using OfflineIMAP")
#     version = __version__
#     description = ugettext_lazy(
#         "Migrate existing mailboxes using IMAP and OfflineIMAP"
#     )
# 
#     def load(self):
#         """Load extension."""
#         param_tools.registry.add(
#             "global", forms.ParametersForm, _("IMAP migration"))
# 
# Path: modoboa_imap_migration/models.py
# class Migration(models.Model):
#     """Represent mailboxes to migrate."""
# 
#     provider = models.ForeignKey(EmailProvider, on_delete=models.CASCADE)
#     mailbox = models.ForeignKey(Mailbox, on_delete=models.CASCADE)
#     username = models.CharField(max_length=254, unique=True)
#     _password = models.CharField(max_length=255)
# 
#     def __str__(self):
#         return self.username
# 
#     @property
#     def password(self):
#         """Password getter."""
#         return decrypt(self._password)
# 
#     @password.setter
#     def password(self, value):
#         """Password setter."""
#         self._password = encrypt(value)


import os
import stat
from django.core.management.base import BaseCommand
from django.template.loader import render_to_string
from modoboa.admin.app_settings import load_admin_settings
from modoboa.parameters import tools as param_tools
from ...modo_extension import ImapMigration
from ...models import Migration
"""A management command to create an offlineimap configuration file."""






class Command(BaseCommand):
    """Command definition."""

    help = "Generate an offlineimap configuration file."

    def add_arguments(self, parser):
        """Add extra arguments to command line."""
        parser.add_argument(
            "--output", default="/tmp/offlineimap.conf",
            help="Path of the generated file")

    def handle(self, *args, **options):
        """Entry point."""
        load_admin_settings()

# Path: modoboa_imap_migration/modo_extension.py
# class ImapMigration(ModoExtension):
#     """The ImapMigration extension class."""
# 
#     name = "modoboa_imap_migration"
#     label = ugettext_lazy("IMAP migration using OfflineIMAP")
#     version = __version__
#     description = ugettext_lazy(
#         "Migrate existing mailboxes using IMAP and OfflineIMAP"
#     )
# 
#     def load(self):
#         """Load extension."""
#         param_tools.registry.add(
#             "global", forms.ParametersForm, _("IMAP migration"))
# 
# Path: modoboa_imap_migration/models.py
# class Migration(models.Model):
#     """Represent mailboxes to migrate."""
# 
#     provider = models.ForeignKey(EmailProvider, on_delete=models.CASCADE)
#     mailbox = models.ForeignKey(Mailbox, on_delete=models.CASCADE)
#     username = models.CharField(max_length=254, unique=True)
#     _password = models.CharField(max_length=255)
# 
#     def __str__(self):
#         return self.username
# 
#     @property
#     def password(self):
#         """Password getter."""
#         return decrypt(self._password)
# 
#     @password.setter
#     def password(self, value):
#         """Password setter."""
#         self._password = encrypt(value)


# Path: modoboa_imap_migration/management/commands/generate_offlineimap_config.py
import os
import stat
from django.core.management.base import BaseCommand
from django.template.loader import render_to_string
from modoboa.admin.app_settings import load_admin_settings
from modoboa.parameters import tools as param_tools
from ...modo_extension import ImapMigration
from ...models import Migration

"""A management command to create an offlineimap configuration file."""






class Command(BaseCommand):
    """Command definition."""

    help = "Generate an offlineimap configuration file."

    def add_arguments(self, parser):
        """Add extra arguments to command line."""
        parser.add_argument(
            "--output", default="/tmp/offlineimap.conf",
            help="Path of the generated file")

    def handle(self, *args, **options):
        """Entry point."""
        load_admin_settings()

        ImapMigration().load()