當前位置: 首頁>>代碼示例>>Python>>正文


Python modulefinder.Module方法代碼示例

本文整理匯總了Python中modulefinder.Module方法的典型用法代碼示例。如果您正苦於以下問題:Python modulefinder.Module方法的具體用法?Python modulefinder.Module怎麽用?Python modulefinder.Module使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在modulefinder的用法示例。


在下文中一共展示了modulefinder.Module方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: import_hook

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def import_hook(self, name, caller=None, *args, **kwargs):
        """
        Hook called when ``caller`` imports module ``name``. Store off the
        caller so we can use it later.

        :param name: Name of the module being imported.
        :type name: ``str``
        :param caller: Module object that is importing ``name``.
        :type caller: ``modulefinder.Module``
        :param args: Other args are passed down to
            ``modulefinder.ModuleFinder.import_hook``
        :param kwargs: Other kwargs are passed down to
            ``modulefinder.ModuleFinder.import_hook``
        :return: Return value from ``modulefinder.ModuleFinder.import_hook``
        """
        self._curr_caller = caller
        return modulefinder.ModuleFinder.import_hook(
            self, name, caller, *args, **kwargs
        ) 
開發者ID:Morgan-Stanley,項目名稱:testplan,代碼行數:21,代碼來源:reloader.py

示例2: _get_modules

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def _get_modules(fn):
    finder = modulefinder.ModuleFinder()
    finder.run_script(fn)
    all = []
    for m in finder.modules.values():
        if not isinstance(m, modulefinder.Module):
            continue
        if not m.__file__:
            continue
        # skip shared object files
        if m.__file__.endswith('.so'):
            continue
        # skip mac system stuff...
        # FIXME: would need to augment with  other OS's system stuff
        if m.__file__.startswith('/Library/Frameworks'):
            continue
        all.append(m)
    return all 
開發者ID:intelxed,項目名稱:xed,代碼行數:20,代碼來源:importfinder.py

示例3: import_module

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def import_module(self, *args, **kwargs):
        """
        Called a bit further down the stack when a module is imported. Update
        the internal mapping of module dependencies.

        :param args: all args are passed down to
            ``modulefinder.ModuleFinder.import_module``
        :param kwargs: all kwargs are passed down to
            ``modulefinder.ModuleFinder.import_module``
        :return: Imported module object.
        :rtype: ``modulefinder.Module``
        """
        caller = self._curr_caller
        self._curr_caller = None
        mod = modulefinder.ModuleFinder.import_module(self, *args, **kwargs)

        if (
            (caller is not None)
            and (mod is not None)
            and _has_file(mod)
            and mod not in self._module_deps[caller]
        ):
            self.logger.debug(
                "Adding %(mod)s to %(caller)s's dependencies",
                {"mod": mod.__name__, "caller": caller.__name__},
            )
            self._module_deps[caller].append(mod)

        return mod 
開發者ID:Morgan-Stanley,項目名稱:testplan,代碼行數:31,代碼來源:reloader.py

示例4: _has_file

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def _has_file(mod):
    """
    :param mod: Module object. Can be any of the multiple types used to
        represent a module, we just check for a __file__ attribute.
    :type mod: ``Any``
    :return: If given module has a not None __file__ attribute.
    :rtype: ``bool``
    """
    return hasattr(mod, "__file__") and mod.__file__ is not None 
開發者ID:Morgan-Stanley,項目名稱:testplan,代碼行數:11,代碼來源:reloader.py

示例5: _module_filepath

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def _module_filepath(module):
    """
    :param module: Module object - either a module itself of its modulefinder
        proxy.
    :type module: ``Union[module, modulefinder.module]``
    :return: the normalised filepath to a module, or None if it has no __file__
        attribute.
    :rtype: ``Optional[str]``
    """
    if not _has_file(module):
        return None
    ret_path = path_utils.fix_home_prefix(os.path.abspath(module.__file__))
    if ret_path.endswith("c"):
        return ret_path[:-1]
    return ret_path 
開發者ID:Morgan-Stanley,項目名稱:testplan,代碼行數:17,代碼來源:reloader.py

示例6: copy_extensions

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def copy_extensions(self, extensions):
        # Get pygame default font
        pygamedir = os.path.split(pygame.base.__file__)[0]
        pygame_default_font = os.path.join(pygamedir, pygame.font.get_default_font())

        # Add font to list of extension to be copied
        extensions.append(Module("pygame.font", pygame_default_font))
        py2exe.build_exe.py2exe.copy_extensions(self, extensions) 
開發者ID:imiolek-ireneusz,項目名稱:eduActiv8,代碼行數:10,代碼來源:eduactiv82exe.py

示例7: copy_extensions

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def copy_extensions(self, _extensions):
        #Get pygame default font
        pygame_dir = os.path.split(pygame.base.__file__)[0]
        pygame_default_font = os.path.join(pygame_dir, pygame.font.get_default_font())
 
        #Add font to list of extension to be copied
        _extensions.append(Module("pygame.font", pygame_default_font))
        py2exe.build_exe.py2exe.copy_extensions(self, _extensions) 
開發者ID:digiholic,項目名稱:universalSmashSystem,代碼行數:10,代碼來源:pygame2exe.py

示例8: copy_extensions

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def copy_extensions(self, extensions):
        #Get pygame default font
        pygamedir = os.path.split(pygame.base.__file__)[0]
        pygame_default_font = os.path.join(pygamedir, pygame.font.get_default_font())

        #Add font to list of extension to be copied
        extensions.append(Module("pygame.font", pygame_default_font))
        py2exe.build_exe.py2exe.copy_extensions(self, extensions) 
開發者ID:rodrigets,項目名稱:games-in-pygame,代碼行數:10,代碼來源:build.py

示例9: _produce_graph

# 需要導入模塊: import modulefinder [as 別名]
# 或者: from modulefinder import Module [as 別名]
def _produce_graph(self, mod, processed):
        """
        Recursive function to build a graph of dependencies.

        :param mod: Module to use for the tree root.
        :type mod: ``modulefinder.Module``
        :param processed: List of modules processed so far in this branch, in
            order of processing. Used to avoid infinite recursion in the case
            of circular dependencies.
        :type processed: ``List[modulefinder.Module]``
        :raises RuntimeError: If ``mod`` is in ``processed`` - the calling
            function should ensure it is not asking to process a module that
            has already been processed.
        :return: Root node of dependency graph.
        :rtype: ``_ModuleNode``
        """
        self.logger.debug(
            "Creating node in dependency graph for module %s", mod.__name__
        )

        if mod in processed:
            raise RuntimeError(
                "Module {mod} has already been processed in this branch. "
                "Already processed = {processed}".format(
                    mod=mod.__name__, processed=processed
                )
            )

        # Create a new list of processed modules to avoid mutating the list
        # we were passed.
        new_processed = processed + [mod]

        # If this module has already been processed in another branch, we
        # can short circuit and return the existing node.
        if mod in self._module_nodes:
            return self._module_nodes[mod]

        # Now for the recursive step - produce a sub-graph of the dependencies
        # of each of our dependencies first, then attach each one to the set
        # of dependencies for the current node. Check that each dependency
        # has not already been processed in this branch to avoid circular
        # dependencies causing infinite recursion.
        dependencies = [
            self._produce_graph(mod=dep, processed=new_processed)
            for dep in self._module_deps[mod]
            if dep not in new_processed
        ]
        node = _ModuleNode(mod, dependencies)
        self._module_nodes[mod] = node
        return node 
開發者ID:Morgan-Stanley,項目名稱:testplan,代碼行數:52,代碼來源:reloader.py


注:本文中的modulefinder.Module方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。