Dynamically creates a module named defined by the PEP-8 version of
   the string contained in service_name (from the YAML config). This
   module will contain a Client class, a Call Factory, and list of API
   definition objects.
3011
def create_service_module(service_name, apis):
   
   service_module = imp.new_module(service_name.lower())

   for api in apis:
      setattr(service_module, api.__class__.__name__, api)

   ClientClass = create_rest_client_class(service_name, apis)

   setattr(service_module, 'resources', tuple(apis))
   setattr(service_module, 'Client', ClientClass)

   sys.modules[service_name.lower()] = service_module
   return service_module
1241013
def factory(type, module=None, **kwargs):
    
    cls = type
    if module is None: module = __name__
    fn = lambda member: inspect.isclass(member) and member.__module__==module
    classes = odict(inspect.getmembers(sys.modules[module], fn))
    members = odict([(k.lower(),v) for k,v in classes.items()])
    lower = cls.lower()
    if lower not in list(members.keys()):
        msg = "Unrecognized class: %s.%s"%(module,cls)
        raise KeyError(msg)
    return members[lower](**kwargs)
738741
def load_module(self, mod):
        
        try:
            return sys.modules[mod]
        except KeyError:
            pass

        lib = ExtensionImporter.extension_modules[mod]
        m = imp.load_dynamic(mod, lib)
        sys.modules[mod] = m
        return m
1032970
def create_command(self, name, operation, **kwargs):
        
        if not isinstance(operation, six.string_types):
            raise ValueError("Operation must be a string. Got '{}'".format(operation))

        name = ' '.join(name.split())

        client_factory = kwargs.get('client_factory', None)

        def _command_handler(command_args):
            op = CLICommandsLoader._get_op_handler(operation)
            client = client_factory(command_args) if client_factory else None
            result = op(client, **command_args) if client else op(**command_args)
            return result

        def arguments_loader():
            return list(extract_args_from_signature(CLICommandsLoader._get_op_handler(operation),
                                                    excluded_params=self.excluded_command_handler_args))

        def description_loader():
            return extract_full_summary_from_signature(CLICommandsLoader._get_op_handler(operation))

        kwargs['arguments_loader'] = arguments_loader
        kwargs['description_loader'] = description_loader

        cmd = self.command_cls(self.cli_ctx, name, _command_handler, **kwargs)
        return cmd
805548
def load_module(self, name):
        
        _verbose_message('namespace module loaded with path {!r}', self.path)

        # Adjusting code from LoaderBasics
        if name in sys.modules:
            mod = sys.modules[name]
            self.exec_module(mod)
            # In this case we do not want to remove the module in case of error
            # Ref : https://docs.python.org/3/reference/import.html#loaders
        else:
            try:
                # Building custom spec and loading as in _LoaderBasics...
                spec = ModuleSpec(name, self, origin='namespace', is_package=True)
                spec.submodule_search_locations = self.path

                # this will call create_module and also initialize the module properly (like for py3)
                mod = module_from_spec(spec)

                # as per https://docs.python.org/3/reference/import.html#loaders
                assert mod.__name__ in sys.modules

                self.exec_module(mod)
                # We don't ensure that the import-related module attributes get
                # set in the sys.modules replacement case.  Such modules are on
                # their own.
            except:
                # as per https://docs.python.org/3/reference/import.html#loaders
                if name in sys.modules:
                    del sys.modules[name]
                raise

        return sys.modules[name]
992218
protected Module createModule(final TwillContext context) {
    return Modules.combine(
      new ConfigModule(cConf, hConf),
      new IOModule(),
      new ZKClientModule(),
      new MetricsClientRuntimeModule().getDistributedModules(),
      new LocationRuntimeModule().getDistributedModules(),
      new DiscoveryRuntimeModule().getDistributedModules(),
      new DataFabricModules().getDistributedModules(),
      new AbstractModule() {
        @Override
        protected void configure() {
          // For Binding queue stuff
          bind(QueueReaderFactory.class).in(Scopes.SINGLETON);

          // For program loading
          install(createProgramFactoryModule());

          // For binding DataSet transaction stuff
          install(new DataFabricFacadeModule());

          bind(ServiceAnnouncer.class).toInstance(new ServiceAnnouncer() {
            @Override
            public Cancellable announce(String serviceName, int port) {
              return context.announce(serviceName, port);
            }
          });
        }
      }
    );
  }
1147054
def module_for(args)
      registry = self
      mod = Module.new

      args.each do |visibility, exports|
        exports.each do |dependency_name, method_name|
          # equivalent to (e.g.):
          #
          #   def foo
          #     registry.fetch(:foo)
          #   end
          mod.send(:define_method, method_name) do
            registry.fetch(dependency_name)
          end

          # equivalent to (e.g.):
          #
          #   private :foo
          mod.send(visibility, method_name)
        end
      end

      mod
    end
1202433
def _from_class(cls, class_name, module_name=None, *args, **kwargs):
        
        def _get_module(module_name):
            names = module_name.split(".")
            module = __import__(names[0])
            for i in xrange(1, len(names)):
                module = getattr(module, names[i])
            return module

        if module_name:
            # module = globals()[module_name]
            # module = __import__(module_name)
            module = _get_module(module_name)
            class_ = getattr(module, class_name)
        else:
            class_ = globals()[class_name]

        if not issubclass(class_, PersistentObject):
            t = class_.__name__, PersistentObject.__name__
            raise TypeError, 'Requested object type %s must be subtype of %s ' % t

        # workaround to mimic FactoryType to work well with FactoryObject.
        name = str(args[0]) if args else cls.__name__
        name = kwargs['name'] if 'name' in kwargs else name
        if hasattr(cls, 'get'):
            instance = cls.get(name)
            if instance:
                return instance

        instance = class_.__new__(class_, *args, **kwargs)
        instance.__init__(*args, **kwargs)
        return instance
279436
def create_module(base_module, name)
      desired_class = camelize(name)
      possible_suffixes = [''] + %w{1 2 3 4 5 6 7 8 9 10}
      if suffix = possible_suffixes.find {|e|
        !base_module.const_defined?(desired_class+e) }
          base_module.const_set(desired_class+suffix, Module.new)
      end
    end
1364091
def load_from_namespace(module_name):
        
        class_inst = None
        name = "py3status.modules.{}".format(module_name)
        py_mod = __import__(name)
        components = name.split(".")
        for comp in components[1:]:
            py_mod = getattr(py_mod, comp)
        class_inst = py_mod.Py3status()
        return class_inst
1052417
function makeModulesGetHostnameProto(module, version, instance) {
  var getHostnameRequest = new apphosting.GetHostnameRequest();
  getHostnameRequest.setModule(module);
  getHostnameRequest.setVersion(version);
  getHostnameRequest.setInstance(instance);
  return getHostnameRequest;
}
1309945
function createModule(module) {
        var moduleInstance,
            moduleId;

        if (typeof module === 'function') {
            try {
                moduleInstance = module();
            } catch (ex) {
                if (module.getId) {
                    moduleId = module.getId();
                } else {
                    moduleId = module.name;
                }

                error('Failed to create an instance of module "' + moduleId + '".',
                      'Application will continue running without the module. ' +
                      'See following exception stack for more details.',
                      ex.stack);
            }
        } else {
            moduleInstance = module;
        }

        addOne(moduleInstances, moduleInstance);

        return moduleInstance;
    }
520507
def dynamic_class_import(class_path):
    
    # Split first occurrence of path
    try:
        tmp = class_path.split(".")
        module_path = ".".join(tmp[0:-1])
        package = __import__(module_path)
        return reduce(getattr, tmp[1:], package)
    except Exception as e:
        log.exception(e)
        log.error(LOGMSG_ERR_FAB_ADDON_IMPORT.format(class_path, e))
141395
function configure(name, service) {
	if (!name) {
		throw new Error('Please specify a name for the client');
	}
	if (name === 'configure' || name === 'client') {
		throw new Error('Cannot register service with reserved name: ' + name);
	}
	module.exports[name] = new Client(service);
}
1088791
def new_module(name):
    
    parent = None
    if '.' in name:
        parent_name = name.rsplit('.', 1)[0]
        parent = __import__(parent_name, fromlist=[''])

    module = imp.new_module(name)
    sys.modules[name] = module
    if parent:
        setattr(parent, name.rsplit('.', 1)[1], module)
    return module
1013180
def _generate_create_callable(name, display_name, arguments, regex, doc, supported, post_arguments, is_action):
    
    def f(self, *args, **kwargs):
        for key, value in args[-1].items():
            if type(value) == file:
                return self._put_or_post_multipart('POST', self._generate_url(regex, args[:-1]), args[-1])
        return self._put_or_post_json('POST', self._generate_url(regex, args[:-1]), args[-1])
    if is_action:
        f.__name__ = str(name)
    else:
        f.__name__ = str('create_%s' % name)
    f.__doc__ = doc
    f._resource_uri = regex
    f._get_args = arguments
    f._put_or_post_args = post_arguments
    f.resource_name = display_name
    f.is_api_call = True
    f.is_supported_api = supported
    return f
683070
def load_module(name, globals_dict=None, symb_list=None):
    
    _load("scapy.modules." + name,
          globals_dict=globals_dict, symb_list=symb_list)