Dynamically import engines that initialize successfully.
333823
def _init():
    """"""
    import importlib
    import os
    import re

    filenames = os.listdir(os.path.dirname(__file__))

    module_names = set()
    for filename in filenames:
        match = re.match(r'^(?P<name>[A-Z_a-z]\w*)\.py[co]?$', filename)
        if match:
            module_names.add(match.group('name'))

    for module_name in module_names:
        try:
            module = importlib.import_module('.' + module_name, __name__)
        except ImportError:
            continue

        for name, member in module.__dict__.items():
            if not isinstance(member, type):
                # skip non-new-style classes
                continue
            if not issubclass(member, Engine):
                # skip non-subclasses of Engine
                continue
            if member is Engine:
                # skip "abstract" class Engine
                continue

            try:
                handle = member.handle
            except AttributeError:
                continue

            engines[handle] = member
695799
def initialize():
    
    global is_initialized
    # Add the custom multi-constructor
    yaml.add_multi_constructor('!obj:', multi_constructor)
    yaml.add_multi_constructor('!pkl:', multi_constructor_pkl)
    yaml.add_multi_constructor('!import:', multi_constructor_import)
    yaml.add_multi_constructor('!include:', multi_constructor_include)

    def import_constructor(loader, node):
        value = loader.construct_scalar(node)
        return try_to_import(value)

    yaml.add_constructor('!import', import_constructor)
    yaml.add_implicit_resolver(
        '!import',
        re.compile(r'(?:[a-zA-Z_][\w_]+\.)+[a-zA-Z_][\w_]+')
    )
    is_initialized = True
146711
def init(**kwargs):
    

    # TODO: Iterate through all engines in name set.
    database = kwargs.pop('database', False)
    if database and not database_exists(engine['default'].url):
        create_database(engine['default'].url, encoding='utf8')
        clear_cache()

    expression = lambda target, table: table.create(target)
    test = lambda target, table: table.exists(target)
    op(expression, test=test, primary='init', secondary='create', **kwargs)
710409
def load_modules(self, args):
        """"""

        # Init the plugins dict
        # Active plugins dictionnary
        self._plugins = collections.defaultdict(dict)
        # Load the plugins
        self.load_plugins(args=args)

        # Init the export modules dict
        # Active exporters dictionnary
        self._exports = collections.defaultdict(dict)
        # All available exporters dictionnary
        self._exports_all = collections.defaultdict(dict)
        # Load the export modules
        self.load_exports(args=args)

        # Restoring system path
        sys.path = sys_path
1183755
def instantiate_modules
      mods = Array(modules)
      mods = load!(mods) if callback?(:load)
      Array(mods).map do |klass|
        init!(klass) || klass.new(fetchable)
      end
    end
592774
public void setImports(String[] imports) {
        module.bind(CodegenModule.IMPORTS, new HashSet<String>(Arrays.asList(imports)));
    }
1267862
def init(name, languages, run):
    """"""
    contents = [file_name for file_name in glob.glob("*.*") if file_name != "brains.yaml"]

    with open(CONFIG_FILE, "w") as output:
        output.write(yaml.safe_dump({
            "run": run,
            "name": name,
            "languages": languages,
            # automatically insert all root files into contents
            "contents": contents,
        }, default_flow_style=False))

    print ""
    cprint("Automatically including the follow files in brain contents:", "cyan")
    for file_name in contents:
        print "\t", file_name
    print ""
    cprint("done! brains.yaml created", 'green')
1119300
def add_the_init(root_dir, data):
  """"""
  init_file = os.path.join(root_dir, '{dataset_type}', '__init__.py')
  context = (
      'from tensorflow_datasets.{dataset_type}.{dataset_name} import '
      '{dataset_cls}  # {TODO} Sort alphabetically\n'
  )
  with gfile.GFile(init_file.format(**data), 'a') as f:
    f.write(context.format(**data))
1166582
def init_module(filesystem):
    """"""
    # pylint: disable=protected-access
    FakePath.filesystem = filesystem
    FakePathlibModule.PureWindowsPath._flavour = _FakeWindowsFlavour(
        filesystem)
    FakePathlibModule.PurePosixPath._flavour = _FakePosixFlavour(filesystem)
907097
@PostConstruct
    public synchronized void initialize() {
        final FwCoreDirection direction = assistCoreDirection();
        developmentHere = direction.isDevelopmentHere();

        final JsonResourceProvider provider = direction.assistJsonResourceProvider();
        mappingOption = OptionalThing.ofNullable(extractMappingOption(provider), () -> {
            throw new IllegalStateException("Not found the JSON mapping option.");
        });
        printControlState = OptionalThing.of(preparePrintState(provider)); // fixedly exists for now
        yourEngineCreator = OptionalThing.ofNullable(extractYourEngineCreator(provider), () -> {
            throw new IllegalStateException("Not found the your engine creator.");
        });

        // should be last because of using other instance variable
        realJsonEngine = createDefaultJsonEngine();
        showBootLogging();
    }
717896
def _init_io_module():
    """"""
    plist = ctypes.POINTER(ctypes.c_void_p)()
    size = ctypes.c_uint()
    check_call(_LIB.MXListDataIters(ctypes.byref(size), ctypes.byref(plist)))
    module_obj = sys.modules[__name__]
    for i in range(size.value):
        hdl = ctypes.c_void_p(plist[i])
        dataiter = _make_io_iterator(hdl)
        setattr(module_obj, dataiter.__name__, dataiter)
113123
def __execute_fromimport(module, modname, import_tuples, verbose=False):
    
    if verbose:
        print('[UTIL_IMPORT] EXECUTING %d FROM IMPORT TUPLES' % (len(import_tuples),))
    from_imports = __get_from_imports(import_tuples)
    for name, fromlist in from_imports:
        full_modname = '.'.join((modname, name))
        tmp = __import__(full_modname, globals(), locals(), fromlist=fromlist, level=0)
        for attrname in fromlist:
            setattr(module, attrname, getattr(tmp, attrname))
    return from_imports
6076
def my_import(name, path=None):
    """"""

    # Documentation for importlib says this may be needed to pick up
    # modules created after the program has started
    if hasattr(importlib, 'invalidate_caches'):
        # python 3.3+
        importlib.invalidate_caches()

    if path is not None:
        directory, src_file = os.path.split(path)

        # TODO: use the importlib.util machinery
        sys.path.insert(0, directory)
        try:
            mod = importlib.import_module(name)
        finally:
            sys.path.pop(0)

    else:
        mod = importlib.import_module(name)

    return mod
972911
def OnImport(self, event):
        """"""

        # Get filepath from user

        wildcards = get_filetypes2wildcards(["csv", "txt"]).values()
        wildcard = "|".join(wildcards)

        message = _("Choose file to import.")
        style = wx.OPEN
        filepath, filterindex = \
            self.interfaces.get_filepath_findex_from_user(wildcard, message,
                                                          style)

        if filepath is None:
            return

        # Get generator of import data
        import_data = self.main_window.actions.import_file(filepath,
                                                           filterindex)

        if import_data is None:
            return

        # Paste import data to grid
        grid = self.main_window.grid
        tl_cell = grid.GetGridCursorRow(), grid.GetGridCursorCol()

        grid.actions.paste(tl_cell, import_data)

        self.main_window.grid.ForceRefresh()
1280997
def init(paths, output, **kwargs):
    
    dp = goodtables.init_datapackage(paths)

    click.secho(
        json_module.dumps(dp.descriptor, indent=4),
        file=output
    )

    exit(dp.valid)
1202549
def _engine_builder(con):
    
    global _SQLALCHEMY_INSTALLED
    if isinstance(con, str):
        try:
            import sqlalchemy
        except ImportError:
            _SQLALCHEMY_INSTALLED = False
        else:
            con = sqlalchemy.create_engine(con)
            return con

    return con
338638
def init(self):
        
        # import any compiled resource modules
        if not self._initialized:
            self._initialized = True
            wrap = projexui.qt.QT_WRAPPER.lower()
            ignore = lambda x: not x.split('.')[-1].startswith(wrap)
            projex.importmodules(self.plugins(), ignore=ignore)