# Path: randtalkbot/errors.py
# class EmptyLanguagesError(Exception):
#     pass
# 
# class SexError(Exception):
#     def __init__(self, sex):
#         super(SexError, self).__init__(
#             'Unknown sex: \"{}\" -- is not a valid sex name.'.format(sex),
#             )
#         self.name = sex
# 
# class StrangerError(Exception):
#     pass
# 
# Path: randtalkbot/i18n.py
# def get_languages_codes(names):
#     """Raises:
#         LanguageNotFoundError: If unable to recognize some language.
# 
#     Returns:
#         list<str>: Deduplicated list of languages' codes.
#     """
#     names = ''.join([c for c in names if c not in QUOTES])
# 
#     if names.strip().lower() in SAME_LANGUAGE_NAMES:
#         return ['same']
# 
#     names = [name.strip() for name in names.split(',')]
#     compact_names = filter(bool, names)
#     languages_codes = map(_get_language_code, compact_names)
#     unique_languages_codes = _get_deduplicated(languages_codes)
#     return unique_languages_codes
# 
# def get_languages_names(codes):
#     """Raises:
#         LanguageNotFoundError: If unable to recognize some language.
# 
#     Returns:
#         str: Comma-separated list of languages' names.
#     """
#     names = map(_get_language_name, codes)
#     return ', '.join(names)
# 
# class LanguageNotFoundError(Exception):
#     def __init__(self, name):
#         super(LanguageNotFoundError, self).__init__('Language \"{0}\" wasn\'t found.'.format(name))
#         self.name = name
# 
# SUPPORTED_LANGUAGES_NAMES = list(zip(*SUPPORTED_LANGUAGES_NAMES_CHOICES))[1]
# 
# Path: randtalkbot/stranger.py
# SEX_NAMES = list(zip(*SEX_CHOICES))[1]
# 
# Path: randtalkbot/stranger_sender_service.py
# class StrangerSenderService:
#     _instance = None
# 
#     def __init__(self, bot):
#         self._bot = bot
#         self._stranger_senders = {}
# 
#     @classmethod
#     def get_instance(cls, bot=None):
#         if cls._instance is None:
#             if bot is None:
#                 raise StrangerSenderServiceError(
#                     'Instance wasn\'t initialized. Provide arguments to construct one.',
#                     )
#             else:
#                 cls._instance = cls(bot)
# 
#         return cls._instance
# 
#     def get_cache_size(self):
#         return len(self._stranger_senders)
# 
#     def get_or_create_stranger_sender(self, stranger):
#         try:
#             return self._stranger_senders[stranger.telegram_id]
#         except KeyError:
#             stranger_sender = StrangerSender(self._bot, stranger)
#             self._stranger_senders[stranger.telegram_id] = stranger_sender
#             return stranger_sender
# 
# Path: randtalkbot/wizard.py
# class Wizard:
#     async def activate(self):
#         raise NotImplementedError()
# 
#     async def deactivate(self):
#         raise NotImplementedError()
# 
#     async def handle(self, message):
#         """Raises:
#             NotImplementedError: Abstract method needs to be implemented.
# 
#         Returns:
#             bool: `True` if message was interpreted in this method. `False` if message still needs
#                 interpretation.
#         """
#         raise NotImplementedError()


import logging
from telepot.exception import TelegramError
from .errors import EmptyLanguagesError, SexError, StrangerError
from .i18n import get_languages_codes, get_languages_names, LanguageNotFoundError, \
    SUPPORTED_LANGUAGES_NAMES
from .stranger import SEX_NAMES
from .stranger_sender_service import StrangerSenderService
from .wizard import Wizard
                            ),
                        )
                else:
                    self._sender.update_translation()
                    self._stranger.wizard_step = 'sex'
                    self._stranger.save()

                await self._prompt()
            elif self._stranger.wizard_step == 'sex':
                try:
                    self._stranger.set_sex(message.text)
                except SexError as err:
                    LOGGER.info('Stranger\'s sex wasn\'t parsed: \"%s\"', message.text)
                    await self._sender.send_notification(
                        _('Unknown sex: \"{0}\" -- is not a valid sex name.'),
                        err.name,
                        )
                    await self._prompt()
                else:
                    if self._stranger.sex == 'not_specified':
                        self._stranger.partner_sex = 'not_specified'
                        # Calls Stranger.save() inside.
                        await self.deactivate()
                    else:
                        self._stranger.wizard_step = 'partner_sex'
                        self._stranger.save()
                        await self._prompt()
            elif self._stranger.wizard_step == 'partner_sex':
                try:
                    self._stranger.set_partner_sex(message.text)

# Path: randtalkbot/errors.py
# class EmptyLanguagesError(Exception):
#     pass
# 
# class SexError(Exception):
#     def __init__(self, sex):
#         super(SexError, self).__init__(
#             'Unknown sex: \"{}\" -- is not a valid sex name.'.format(sex),
#             )
#         self.name = sex
# 
# class StrangerError(Exception):
#     pass
# 
# Path: randtalkbot/i18n.py
# def get_languages_codes(names):
#     """Raises:
#         LanguageNotFoundError: If unable to recognize some language.
# 
#     Returns:
#         list<str>: Deduplicated list of languages' codes.
#     """
#     names = ''.join([c for c in names if c not in QUOTES])
# 
#     if names.strip().lower() in SAME_LANGUAGE_NAMES:
#         return ['same']
# 
#     names = [name.strip() for name in names.split(',')]
#     compact_names = filter(bool, names)
#     languages_codes = map(_get_language_code, compact_names)
#     unique_languages_codes = _get_deduplicated(languages_codes)
#     return unique_languages_codes
# 
# def get_languages_names(codes):
#     """Raises:
#         LanguageNotFoundError: If unable to recognize some language.
# 
#     Returns:
#         str: Comma-separated list of languages' names.
#     """
#     names = map(_get_language_name, codes)
#     return ', '.join(names)
# 
# class LanguageNotFoundError(Exception):
#     def __init__(self, name):
#         super(LanguageNotFoundError, self).__init__('Language \"{0}\" wasn\'t found.'.format(name))
#         self.name = name
# 
# SUPPORTED_LANGUAGES_NAMES = list(zip(*SUPPORTED_LANGUAGES_NAMES_CHOICES))[1]
# 
# Path: randtalkbot/stranger.py
# SEX_NAMES = list(zip(*SEX_CHOICES))[1]
# 
# Path: randtalkbot/stranger_sender_service.py
# class StrangerSenderService:
#     _instance = None
# 
#     def __init__(self, bot):
#         self._bot = bot
#         self._stranger_senders = {}
# 
#     @classmethod
#     def get_instance(cls, bot=None):
#         if cls._instance is None:
#             if bot is None:
#                 raise StrangerSenderServiceError(
#                     'Instance wasn\'t initialized. Provide arguments to construct one.',
#                     )
#             else:
#                 cls._instance = cls(bot)
# 
#         return cls._instance
# 
#     def get_cache_size(self):
#         return len(self._stranger_senders)
# 
#     def get_or_create_stranger_sender(self, stranger):
#         try:
#             return self._stranger_senders[stranger.telegram_id]
#         except KeyError:
#             stranger_sender = StrangerSender(self._bot, stranger)
#             self._stranger_senders[stranger.telegram_id] = stranger_sender
#             return stranger_sender
# 
# Path: randtalkbot/wizard.py
# class Wizard:
#     async def activate(self):
#         raise NotImplementedError()
# 
#     async def deactivate(self):
#         raise NotImplementedError()
# 
#     async def handle(self, message):
#         """Raises:
#             NotImplementedError: Abstract method needs to be implemented.
# 
#         Returns:
#             bool: `True` if message was interpreted in this method. `False` if message still needs
#                 interpretation.
#         """
#         raise NotImplementedError()


# Path: randtalkbot/stranger_setup_wizard.py
import logging
from telepot.exception import TelegramError
from .errors import EmptyLanguagesError, SexError, StrangerError
from .i18n import get_languages_codes, get_languages_names, LanguageNotFoundError, \
    SUPPORTED_LANGUAGES_NAMES
from .stranger import SEX_NAMES
from .stranger_sender_service import StrangerSenderService
from .wizard import Wizard

                            ),
                        )
                else:
                    self._sender.update_translation()
                    self._stranger.wizard_step = 'sex'
                    self._stranger.save()

                await self._prompt()
            elif self._stranger.wizard_step == 'sex':
                try:
                    self._stranger.set_sex(message.text)
                except SexError as err:
                    LOGGER.info('Stranger\'s sex wasn\'t parsed: \"%s\"', message.text)
                    await self._sender.send_notification(
                        _('Unknown sex: \"{0}\" -- is not a valid sex name.'),
                        err.name,
                        )
                    await self._prompt()
                else:
                    if self._stranger.sex == 'not_specified':
                        self._stranger.partner_sex = 'not_specified'
                        # Calls Stranger.save() inside.
                        await self.deactivate()
                    else:
                        self._stranger.wizard_step = 'partner_sex'
                        self._stranger.save()
                        await self._prompt()
            elif self._stranger.wizard_step == 'partner_sex':
                try:
                    self._stranger.set_partner_sex(message.text)

                except SexError as err: