# Path: zdict/constants.py
# VERSION = '4.0.5'
# BASE_DIR_NAME = '.zdict'
# BASE_DIR = os.path.join(os.path.expanduser("~"), BASE_DIR_NAME)
# DB_NAME = 'zdict.db'
# DB_FILE = os.path.join(BASE_DIR, DB_NAME)
# 
# Path: zdict/utils.py
# def create_zdict_dir_if_not_exists():
# def create_zdict_db_if_not_exists():
# def check_zdict_dir_and_db():
#     def __getattr__(cls, color):
#     def set_force_color(cls, force_color=True):
#     def format(self, s='', color='org', indent=0):
#     def print(self, *args, end='\n', **kwargs):
# def import_readline():
# class ColorConst(type):
# class Color(metaclass=ColorConst):
#     COLOR_TEMPLATE = "\33[{}m"
#     COLOR_LIST = (
#         ('ORG', 0),
#         ('BLACK', 30),
#         ('RED', 31),
#         ('GREEN', 32),
#         ('YELLOW', 33),
#         ('BLUE', 34),
#         ('MAGENTA', 35),
#         ('INDIGO', 36),
#         ('WHITE', 37),
#     )
# 
# Path: zdict/easter_eggs.py
# def import_pyjokes_module():
# def get_pyjoke(pyjokes, word: str):
# def show_pyjoke(record: Record):
# def lookup_pyjokes(word: str):
# 
# Path: zdict/api.py
# def dump(pattern=r'^.*$'):
#     return [r.word for r in Record.select() if re.fullmatch(pattern, r.word)]
# 
# Path: zdict/completer.py
# class DictCompleter:
#     def __init__(self):
#         self.db = db
#         self.db.connection()
# 
#     def __del__(self):
#         self.db.close()
# 
#     def complete(self, text, state):
#         if state == 0:  # new query
#             self.records = iter(
#                 Record.select().where(Record.word.startswith(text)))
# 
#         return next(self.records).word
# 
# Path: zdict/loader.py
# def get_dictionary_map():
#     '''
#     Auto discover dictionaries in package ``dictionaries``.
#     Each dictionary class MUST be the subclass of ``DictBase``
# 
#     :return: a dict with {provider_name: cls}
#         SomeDict.provider as key, the class as value
#     '''
#     package = 'zdict.dictionaries'
#     exclude_files = ('template.py',)
# 
#     return {
#         cls(None).provider: cls
#         for _, cls in (
#             chain.from_iterable(
#                 getmembers(mod, predicate=_is_dict)
#                 for mod in (
#                     import_module(
#                         '{}.{}'.format(package, f.partition('.py')[0]))
#                     for f in os.listdir(dictionaries.__path__[0])
#                     if (not f.startswith('_') and
#                         f.endswith('.py') and
#                         f not in exclude_files)
#                 )
#             )
#         )
#     }
# 
# Path: zdict/utils.py
# def create_zdict_dir_if_not_exists():
# def create_zdict_db_if_not_exists():
# def check_zdict_dir_and_db():
#     def __getattr__(cls, color):
#     def set_force_color(cls, force_color=True):
#     def format(self, s='', color='org', indent=0):
#     def print(self, *args, end='\n', **kwargs):
# def import_readline():
# class ColorConst(type):
# class Color(metaclass=ColorConst):
#     COLOR_TEMPLATE = "\33[{}m"
#     COLOR_LIST = (
#         ('ORG', 0),
#         ('BLACK', 30),
#         ('RED', 31),
#         ('GREEN', 32),
#         ('YELLOW', 33),
#         ('BLUE', 34),
#         ('MAGENTA', 35),
#         ('INDIGO', 36),
#         ('WHITE', 37),
#     )


from argparse import ArgumentParser, ArgumentTypeError
from locale import getdefaultlocale
from multiprocessing import Pool
from contextlib import redirect_stdout
from io import StringIO
from zdict import constants, utils, easter_eggs
from zdict.api import dump
from zdict.completer import DictCompleter
from zdict.loader import get_dictionary_map
from zdict.utils import readline, check_zdict_dir_and_db
    import sys
    import signal

    def __del__(self):
        del self.dicts

    def prompt(self):
        user_input = input('[zDict]: ').strip()

        if user_input:
            if self.pool:
                futures = [
                    self.pool.apply_async(lookup_string_wrapper,
                                          (d, user_input, self.args))
                    for d in self.dict_classes
                ]
                results = [i.get() for i in futures]
                print(''.join(results))
            else:
                for dictionary_instance in self.dicts:
                    dictionary_instance.lookup(user_input)
        else:
            return

    def loop_prompt(self):
        while True:
            self.prompt()


def interactive_mode(args):
    # configure readline and completer
    readline.parse_and_bind("tab: complete")

# Path: zdict/constants.py
# VERSION = '4.0.5'
# BASE_DIR_NAME = '.zdict'
# BASE_DIR = os.path.join(os.path.expanduser("~"), BASE_DIR_NAME)
# DB_NAME = 'zdict.db'
# DB_FILE = os.path.join(BASE_DIR, DB_NAME)
# 
# Path: zdict/utils.py
# def create_zdict_dir_if_not_exists():
# def create_zdict_db_if_not_exists():
# def check_zdict_dir_and_db():
#     def __getattr__(cls, color):
#     def set_force_color(cls, force_color=True):
#     def format(self, s='', color='org', indent=0):
#     def print(self, *args, end='\n', **kwargs):
# def import_readline():
# class ColorConst(type):
# class Color(metaclass=ColorConst):
#     COLOR_TEMPLATE = "\33[{}m"
#     COLOR_LIST = (
#         ('ORG', 0),
#         ('BLACK', 30),
#         ('RED', 31),
#         ('GREEN', 32),
#         ('YELLOW', 33),
#         ('BLUE', 34),
#         ('MAGENTA', 35),
#         ('INDIGO', 36),
#         ('WHITE', 37),
#     )
# 
# Path: zdict/easter_eggs.py
# def import_pyjokes_module():
# def get_pyjoke(pyjokes, word: str):
# def show_pyjoke(record: Record):
# def lookup_pyjokes(word: str):
# 
# Path: zdict/api.py
# def dump(pattern=r'^.*$'):
#     return [r.word for r in Record.select() if re.fullmatch(pattern, r.word)]
# 
# Path: zdict/completer.py
# class DictCompleter:
#     def __init__(self):
#         self.db = db
#         self.db.connection()
# 
#     def __del__(self):
#         self.db.close()
# 
#     def complete(self, text, state):
#         if state == 0:  # new query
#             self.records = iter(
#                 Record.select().where(Record.word.startswith(text)))
# 
#         return next(self.records).word
# 
# Path: zdict/loader.py
# def get_dictionary_map():
#     '''
#     Auto discover dictionaries in package ``dictionaries``.
#     Each dictionary class MUST be the subclass of ``DictBase``
# 
#     :return: a dict with {provider_name: cls}
#         SomeDict.provider as key, the class as value
#     '''
#     package = 'zdict.dictionaries'
#     exclude_files = ('template.py',)
# 
#     return {
#         cls(None).provider: cls
#         for _, cls in (
#             chain.from_iterable(
#                 getmembers(mod, predicate=_is_dict)
#                 for mod in (
#                     import_module(
#                         '{}.{}'.format(package, f.partition('.py')[0]))
#                     for f in os.listdir(dictionaries.__path__[0])
#                     if (not f.startswith('_') and
#                         f.endswith('.py') and
#                         f not in exclude_files)
#                 )
#             )
#         )
#     }
# 
# Path: zdict/utils.py
# def create_zdict_dir_if_not_exists():
# def create_zdict_db_if_not_exists():
# def check_zdict_dir_and_db():
#     def __getattr__(cls, color):
#     def set_force_color(cls, force_color=True):
#     def format(self, s='', color='org', indent=0):
#     def print(self, *args, end='\n', **kwargs):
# def import_readline():
# class ColorConst(type):
# class Color(metaclass=ColorConst):
#     COLOR_TEMPLATE = "\33[{}m"
#     COLOR_LIST = (
#         ('ORG', 0),
#         ('BLACK', 30),
#         ('RED', 31),
#         ('GREEN', 32),
#         ('YELLOW', 33),
#         ('BLUE', 34),
#         ('MAGENTA', 35),
#         ('INDIGO', 36),
#         ('WHITE', 37),
#     )


# Path: zdict/zdict.py
from argparse import ArgumentParser, ArgumentTypeError
from locale import getdefaultlocale
from multiprocessing import Pool
from contextlib import redirect_stdout
from io import StringIO
from zdict import constants, utils, easter_eggs
from zdict.api import dump
from zdict.completer import DictCompleter
from zdict.loader import get_dictionary_map
from zdict.utils import readline, check_zdict_dir_and_db
    import sys
    import signal


    def __del__(self):
        del self.dicts

    def prompt(self):
        user_input = input('[zDict]: ').strip()

        if user_input:
            if self.pool:
                futures = [
                    self.pool.apply_async(lookup_string_wrapper,
                                          (d, user_input, self.args))
                    for d in self.dict_classes
                ]
                results = [i.get() for i in futures]
                print(''.join(results))
            else:
                for dictionary_instance in self.dicts:
                    dictionary_instance.lookup(user_input)
        else:
            return

    def loop_prompt(self):
        while True:
            self.prompt()


def interactive_mode(args):
    # configure readline and completer
    readline.parse_and_bind("tab: complete")

    readline.set_completer(DictCompleter().complete)