# Path: lightbulb/core/utils/common.py
# def accept_bool(user_input):
#     """
#         Transforms a string into bool
#         Args:
#             user_input (str): The string parameter
#         Retuns:
#             bool: A true or false value
#     """
#     if not isinstance(user_input, basestring):
#         return  user_input
# 
#     if user_input.lower() in ['true', '1', 't', 'y', 'yes']:
#         return True
#     else:
#         return  False
# 
# def findlibrary(path):
#     path = re.sub('.*my_saved_models/', expanduser("~") + "/.LightBulb/models/", path)
#     path = re.sub('.*my_saved_regex/', expanduser("~") + "/.LightBulb/regex/", path)
#     path = re.sub('.*my_saved_trees/', expanduser("~") + "/.LightBulb/trees/", path)
#     path = re.sub('.*my_saved_grammars/', expanduser("~") + "/.LightBulb/grammars/", path)
#     path = path.replace('{library}', imp.find_module('lightbulb')[1]+"/data/")
#     return path
# 
# Path: lightbulb/core/utils/rcadiff.py
# def rca_diff(dfa_a, dfa_b, alphabet, num_diff = 1, dfa1_minus_dfa2 = False):
#     """
#     Args:
#         dfa1 (DFA): The fist DFA
#         dfa2 (DFA): The SECOND DFA
#         alphabet (list): The input alphabet
#         left (boolean): Perform the Diff mma - mmb
#         right (boolean): Perform the Diff mmb - mma
#     Returns:
#         None
#     """
#     if alphabet is None:
#         alphabet = createalphabet()
# 
#     dfa1 = DFA(alphabet)
#     dfa1.init_from_acceptor(dfa_a)
#     dfa2 = DFA(alphabet)
#     dfa2.init_from_acceptor(dfa_b)
#     """
#     Execute algorithm
#     """
#     counterexamples = []
#     mmc = dfa1.diff(dfa2)
#     counterexample = mmc.shortest_string()
#     counterexamples.append(counterexample)
#     if not dfa1_minus_dfa2:
#         mmc = dfa2.diff(dfa1)
#         counterexample = mmc.shortest_string()
#         counterexamples.append(counterexample)
#     return counterexamples
# 
# Path: lightbulb/core/base.py
# def options_as_dictionary(meta):
# def importmodule(name):
# def create_object(object_type, object_type_configuration, handler, handler_configuration):
#         def setup(self, configuration):
#     class Module(object_class):


from sfalearn.angluin_sfa import SFALearner as _SFALearner
from symautomata.cfgpda import CfgPDA as _CfgPDA
from symautomata.dfa import DFA as _DFA
from symautomata.flex2fst import Flexparser as _Flexparser
from lightbulb.core.utils.common import accept_bool, findlibrary
from lightbulb.core.utils.rcadiff import rca_diff
from lightbulb.core.base import createalphabet
        self.cache_equivalence = []
        self.cache_membership = {}
        self.ids_membership_queries = 0
        self.ids_cache_membership_queries = 0
        self.ids_equivalence_queries = 0
        self.ids_cache_equivalence_queries = 0
        self.ids_states = 0
        self.browserstates = 0
        self.cross_check_times = 0
        self.equivalence_queries_cached_membership = 0
        self.ids_equivalence_queries_cached_membership = 0
        self.num_diff = 2
        self.shared_memory = shared_memory
        self.cross = cross
        self.dfa1_minus_dfa2 = accept_bool(self.dfa1_minus_dfa2)
        self.mma = None
        self.mmac = None
        self.pda = None
        self.bypass = None

        if self.seed_file is not None and self.seed_file_type is not None:
            if self.seed_file_type == "FLEX":
                flex_object_m = _Flexparser(self.alphabet)
                self.mma = flex_object_m.yyparse(findlibrary(self.seed_file))
                self.mma.minimize()
            elif self.seed_file_type == "GRAMMAR":
                cfgtopda = _CfgPDA(self.alphabet)
                self.mma = cfgtopda.yyparse(findlibrary(self.seed_file), 1)
            elif self.seed_file_type == "FST":
                self.mma = _DFA(self.alphabet)

# Path: lightbulb/core/utils/common.py
# def accept_bool(user_input):
#     """
#         Transforms a string into bool
#         Args:
#             user_input (str): The string parameter
#         Retuns:
#             bool: A true or false value
#     """
#     if not isinstance(user_input, basestring):
#         return  user_input
# 
#     if user_input.lower() in ['true', '1', 't', 'y', 'yes']:
#         return True
#     else:
#         return  False
# 
# def findlibrary(path):
#     path = re.sub('.*my_saved_models/', expanduser("~") + "/.LightBulb/models/", path)
#     path = re.sub('.*my_saved_regex/', expanduser("~") + "/.LightBulb/regex/", path)
#     path = re.sub('.*my_saved_trees/', expanduser("~") + "/.LightBulb/trees/", path)
#     path = re.sub('.*my_saved_grammars/', expanduser("~") + "/.LightBulb/grammars/", path)
#     path = path.replace('{library}', imp.find_module('lightbulb')[1]+"/data/")
#     return path
# 
# Path: lightbulb/core/utils/rcadiff.py
# def rca_diff(dfa_a, dfa_b, alphabet, num_diff = 1, dfa1_minus_dfa2 = False):
#     """
#     Args:
#         dfa1 (DFA): The fist DFA
#         dfa2 (DFA): The SECOND DFA
#         alphabet (list): The input alphabet
#         left (boolean): Perform the Diff mma - mmb
#         right (boolean): Perform the Diff mmb - mma
#     Returns:
#         None
#     """
#     if alphabet is None:
#         alphabet = createalphabet()
# 
#     dfa1 = DFA(alphabet)
#     dfa1.init_from_acceptor(dfa_a)
#     dfa2 = DFA(alphabet)
#     dfa2.init_from_acceptor(dfa_b)
#     """
#     Execute algorithm
#     """
#     counterexamples = []
#     mmc = dfa1.diff(dfa2)
#     counterexample = mmc.shortest_string()
#     counterexamples.append(counterexample)
#     if not dfa1_minus_dfa2:
#         mmc = dfa2.diff(dfa1)
#         counterexample = mmc.shortest_string()
#         counterexamples.append(counterexample)
#     return counterexamples
# 
# Path: lightbulb/core/base.py
# def options_as_dictionary(meta):
# def importmodule(name):
# def create_object(object_type, object_type_configuration, handler, handler_configuration):
#         def setup(self, configuration):
#     class Module(object_class):


# Path: lightbulb/core/modules/sfadiff.py
from sfalearn.angluin_sfa import SFALearner as _SFALearner
from symautomata.cfgpda import CfgPDA as _CfgPDA
from symautomata.dfa import DFA as _DFA
from symautomata.flex2fst import Flexparser as _Flexparser
from lightbulb.core.utils.common import accept_bool, findlibrary
from lightbulb.core.utils.rcadiff import rca_diff
from lightbulb.core.base import createalphabet

        self.cache_equivalence = []
        self.cache_membership = {}
        self.ids_membership_queries = 0
        self.ids_cache_membership_queries = 0
        self.ids_equivalence_queries = 0
        self.ids_cache_equivalence_queries = 0
        self.ids_states = 0
        self.browserstates = 0
        self.cross_check_times = 0
        self.equivalence_queries_cached_membership = 0
        self.ids_equivalence_queries_cached_membership = 0
        self.num_diff = 2
        self.shared_memory = shared_memory
        self.cross = cross
        self.dfa1_minus_dfa2 = accept_bool(self.dfa1_minus_dfa2)
        self.mma = None
        self.mmac = None
        self.pda = None
        self.bypass = None

        if self.seed_file is not None and self.seed_file_type is not None:
            if self.seed_file_type == "FLEX":
                flex_object_m = _Flexparser(self.alphabet)
                self.mma = flex_object_m.yyparse(findlibrary(self.seed_file))
                self.mma.minimize()
            elif self.seed_file_type == "GRAMMAR":
                cfgtopda = _CfgPDA(self.alphabet)
                self.mma = cfgtopda.yyparse(findlibrary(self.seed_file), 1)
            elif self.seed_file_type == "FST":
                self.mma = _DFA(self.alphabet)

                self.mma.load(findlibrary(self.seed_file))