Adds a module to the list

        Args:
            module_name (str): The name of the module
            module_ui: The function to call to create the module's UI
969055
def add_module(self, module_name, module_ui):
        
        m_button = tk.Label(self.module_selection, text=module_name, bg="white", anchor="w")
        m_button.grid(column=0, row=len(self.module_selection.winfo_children()), padx=0, pady=0, sticky="W E N S")

        self.module_buttons[module_name] = m_button
        m_button.bind("<Button-1>", lambda e: self.module_selected(module_name, module_ui))
955770
def _get_module(module_name=None, module=None, register=True):
    
    if module is None and module_name is not None:
        try:
            module = sys.modules[module_name]
        except KeyError as ex:
            print(ex)
            raise KeyError(('module_name=%r must be loaded before ' +
                            'receiving injections') % module_name)
    elif module is not None and module_name is None:
        pass
    else:
        raise ValueError('module_name or module must be exclusively specified')
    if register is True:
        _add_injected_module(module)
    return module
1329584
def load_module(self, module):
        
        if isinstance(module, basestring) and module.find('.') > -1:
            a = module.split('.')
            module = ('.%s' % a[-1], '.'.join(a[:-1]))
        try:
            module = import_module(*module)
        except Exception, e:
            return e
        
        for name in dir(module):
            if name.startswith('_'): continue
            obj = getattr(module, name)
            if callable(obj):
                for tag in settings.TAG_TYPES:
                    if hasattr(obj, tag) and getattr(obj, tag) in (1, True):
                        name = getattr(obj, 'name', obj.__name__)
                        if name in self[tag]:
                            continue
                        if hasattr(obj, 'name'):
                            self.register(tag, getattr(obj, 'name'), obj)
                        else:
                            self.register(tag, obj)
753465
def from_modulename(cls, module_name):
        
        # XXX make this more robust (pyc files? zip archives? etc)
        slug = module_name.replace('.', '/')
        paths = [slug + '.py', slug + '/__init__.py']

        # always search from current directory
        for base in [''] + sys.path:
            for path in paths:
                fullpath = os.path.join(base, path)
                if os.path.exists(fullpath):
                    return cls(fullpath, prefix=module_name)
        else:
            raise ValueError("Module not found: %s" % module_name)
134232
def augment(module_name, base_class):
    

    for name, cls in inspect.getmembers(sys.modules[module_name],
                                        lambda x : inspect.isclass(x) and  issubclass(x, base_class) ):
        if cls == base_class:
            continue

        cls.augment()
1138697
def linkify_s_by_module(self, modules):
        
        for i in self:

            links_list = strip_and_uniq(i.modules)
            new = []
            for name in [e for e in links_list if e]:
                module = modules.find_by_name(name)
                if module is not None and module.uuid not in new:
                    new.append(module)
                else:
                    i.add_error("Error: the module %s is unknown for %s" % (name, i.get_name()))

            i.modules = new
288318
def _initModuleList(self):
        
        if self.checkVersion('1.4'):
            cmd = "module show"
        else:
            cmd = "show modules"
        cmdresp = self.executeCommand(cmd)
        self._modules = set()
        for line in cmdresp.splitlines()[1:-1]:
            mobj = re.match('\s*(\S+)\s', line)
            if mobj:
                self._modules.add(mobj.group(1).lower())
486165
def add_view_menu(self, name):
        
        view_menu = self.find_view_menu(name)
        if view_menu is None:
            try:
                view_menu = self.viewmenu_model()
                view_menu.name = name
                self.get_session.add(view_menu)
                self.get_session.commit()
                return view_menu
            except Exception as e:
                log.error(c.LOGMSG_ERR_SEC_ADD_VIEWMENU.format(str(e)))
                self.get_session.rollback()
        return view_menu
721533
def list_submodules(module_name: str) -> List[str]:   # pylint: disable=invalid-sequence-index
    
    _module = importlib.import_module(module_name)
    return [module_name+'.'+submodule_name for _, submodule_name, _ in pkgutil.iter_modules(_module.__path__)]
166730
def load_module(name):
    

    spec = importlib.util.find_spec(name)
    mod = importlib.util.module_from_spec(spec)
    mod.__spec__ = spec
    mod.__loader__ = spec.loader
    spec.loader.exec_module(mod)
    return mod
2777
def lookup(self, module_name):
        
        for search_path in self._paths:
            module_path = os.path.join(search_path, module_name)
            new_module_name, module_file = self._lookup(module_path, module_name)
            if module_file:
                return new_module_name, module_file
        return None, None
299354
def registerAddonModule(cls, module):
        
        prop = '_{0}__addon_modules'.format(cls.__name__)
        mods = getattr(cls, prop, set())
        mods.add(module)
        setattr(cls, prop, mods)
527581
def show_modules(config, modules_list):
    
    details = config["full"]
    core_mods = not config["user"]
    user_mods = not config["core"]

    modules = core_module_docstrings(
        include_core=core_mods, include_user=user_mods, config=config
    )

    new_modules = []
    if modules_list:
        from fnmatch import fnmatch

        for _filter in modules_list:
            for name in modules.keys():
                if fnmatch(name, _filter):
                    if name not in new_modules:
                        new_modules.append(name)
    else:
        new_modules = modules.keys()

    for name in sorted(new_modules):
        module = _to_docstring(modules[name])
        desc = module[0][:-1]
        if details:
            dash_len = len(name) + 4
            print("#" * dash_len)
            print("# {} #".format(name))
            print("#" * dash_len)
            for description in module:
                print(description[:-1])
        else:
            print("%-22s %s" % (name, desc))
307836
def pyfrom(mod_name, import: nil)
      raise ArgumentError, "missing identifier(s) to be imported" unless import

      mod_name = mod_name.to_str if mod_name.respond_to? :to_str
      mod_name = mod_name.to_s if mod_name.is_a? Symbol

      import = Array(import)
      fromlist = import.map.with_index do |import_name, i|
        case import_name
        when assoc_array_matcher
          import_name[0]
        when Symbol, String
          import_name
        else
          raise ArgumentError, "wrong type of import name #{import_name.class} (expected String or Symbol)"
        end
      end
      from_list = PyCall.tuple(from_list)

      main_dict_ptr = PyCall.import_module('__main__').__dict__.__pyptr__
      globals = main_dict_ptr # FIXME: this should mimic to `import_name` function defined in `Python/ceval.c`.
      locals = main_dict_ptr # FIXME: this should mimic to `import_name` function defined in `Python/ceval.c`.
      level = 0 # TODO: support prefixed dots (#25)
      mod = LibPython::Helpers.import_module(mod_name, globals, locals, fromlist, level)

      import.each do |import_name|
        case import_name
        when assoc_array_matcher
          name, asname = *import_name
        when Symbol, String
          name, asname = import_name, import_name
        end

        if PyCall::LibPython::Helpers.hasattr?(mod.__pyptr__, name)
          pyobj = PyCall::LibPython::Helpers.getattr(mod.__pyptr__, name)
          define_name(asname, pyobj)
          next
        end

        if mod.respond_to? :__name__
          pkgname = mod.__name__
          fullname = "#{pkgname}.#{name}"
          sys_modules = PyCall.import_module('sys').modules
          if sys_modules.has_key?(fullname)
            pyobj = module_dict[fullname]
            define_name(asname, pyobj)
            next
          end
        end

        raise ArgumentError, "cannot import name #{fullname}" unless pyobj
      end
    end
793061
def load_ui_from_file(name: str):
    
    ui_file = _get_ui_qfile(name)
    try:
        base_type = uic.loadUiType(ui_file, from_imports=True)
    finally:
        ui_file.close()
    return base_type
897059
def import_(module_name, name):
    
    module = importlib.import_module(module_name, __package__)
    return getattr(module, name)
256705
def update(self, module_name=None):
        
        if not module_name:
            return self._module.force_update()
        else:
            module_info = self._get_module_info(module_name)
            if module_info:
                module_info["module"].force_update()