本文整理汇总了Python中sys.meta_path方法的典型用法代码示例。如果您正苦于以下问题:Python sys.meta_path方法的具体用法?Python sys.meta_path怎么用?Python sys.meta_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块sys的用法示例。

在下文中一共展示了sys.meta_path方法的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: ResetModules

​点赞 7

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def ResetModules(self):

"""Clear modules so that when request is run they are reloaded."""

lib_config._default_registry.reset()

self._modules.clear()

self._modules.update(self._default_modules)

sys.path_hooks[:] = self._save_path_hooks

sys.meta_path = []

apiproxy_stub_map.apiproxy.GetPreCallHooks().Clear()

apiproxy_stub_map.apiproxy.GetPostCallHooks().Clear()

开发者ID:elsigh,项目名称:browserscope,代码行数:20,

示例2: load_module

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def load_module(self, fullname):

print('load_module {}'.format(fullname))

if fullname in sys.modules:

return sys.modules[fullname]

# 先从 sys.meta_path 中删除自定义的 finder

# 防止下面执行 import_module 的时候再次触发此 finder

# 从而出现递归调用的问题

finder = sys.meta_path.pop(0)

# 导入 module

module = importlib.import_module(fullname)

module_hook(fullname, module)

sys.meta_path.insert(0, finder)

return module

开发者ID:mozillazg,项目名称:apm-python-agent-principle,代码行数:18,

示例3: find_loader

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def find_loader(name, path=None):

"""Find the loader for the specified module.

First, sys.modules is checked to see if the module was already imported. If

so, then sys.modules[name].__loader__ is returned. If that happens to be

set to None, then ValueError is raised. If the module is not in

sys.modules, then sys.meta_path is searched for a suitable loader with the

value of 'path' given to the finders. None is returned if no loader could

be found.

Dotted names do not have their parent packages implicitly imported. You will

most likely need to explicitly import all parent packages in the proper

order for a submodule to get the correct loader.

"""

try:

loader = sys.modules[name].__loader__

if loader is None:

raise ValueError('{}.__loader__ is None'.format(name))

else:

return loader

except KeyError:

pass

return _bootstrap._find_module(name, path)

开发者ID:war-and-code,项目名称:jawfish,代码行数:26,

示例4: install_hooks

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def install_hooks():

"""

This function installs the future.standard_library import hook into

sys.meta_path.

"""

if PY3:

return

install_aliases()

flog.debug('sys.meta_path was: {0}'.format(sys.meta_path))

flog.debug('Installing hooks ...')

# Add it unless it's there already

newhook = RenameImport(RENAMES)

if not detect_hooks():

sys.meta_path.append(newhook)

flog.debug('sys.meta_path is now: {0}'.format(sys.meta_path))

开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:20,

示例5: remove_hooks

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def remove_hooks(scrub_sys_modules=False):

"""

This function removes the import hook from sys.meta_path.

"""

if PY3:

return

flog.debug('Uninstalling hooks ...')

# Loop backwards, so deleting items keeps the ordering:

for i, hook in list(enumerate(sys.meta_path))[::-1]:

if hasattr(hook, 'RENAMER'):

del sys.meta_path[i]

# Explicit is better than implicit. In the future the interface should

# probably change so that scrubbing the import hooks requires a separate

# function call. Left as is for now for backward compatibility with

# v0.11.x.

if scrub_sys_modules:

scrub_future_sys_modules()

开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:20,

示例6: detect_hooks

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def detect_hooks():

"""

Returns True if the import hooks are installed, False if not.

"""

flog.debug('Detecting hooks ...')

present = any([hasattr(hook, 'RENAMER') for hook in sys.meta_path])

if present:

flog.debug('Detected.')

else:

flog.debug('Not detected.')

return present

# As of v0.12, this no longer happens implicitly:

# if not PY3:

# install_hooks()

开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:18,

示例7: mount

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def mount(self, append=False):

pathname = os.path.abspath(os.path.join(self.dirname, self.filename))

if not self.is_compatible():

msg = 'Wheel %s not compatible with this Python.' % pathname

raise DistlibException(msg)

if not self.is_mountable():

msg = 'Wheel %s is marked as not mountable.' % pathname

raise DistlibException(msg)

if pathname in sys.path:

logger.debug('%s already in path', pathname)

else:

if append:

sys.path.append(pathname)

else:

sys.path.insert(0, pathname)

extensions = self._get_extensions()

if extensions:

if _hook not in sys.meta_path:

sys.meta_path.append(_hook)

_hook.add(pathname, extensions)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,

示例8: _FakeProxyBypassHelper

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def _FakeProxyBypassHelper(fn,

original_module_dict=sys.modules.copy(),

original_uname=os.uname):

"""Setups and restores the state for the Mac OS X urllib fakes."""

def Inner(*args, **kwargs):

current_uname = os.uname

current_meta_path = sys.meta_path[:]

current_modules = sys.modules.copy()

try:

sys.modules.clear()

sys.modules.update(original_module_dict)

sys.meta_path[:] = []

os.uname = original_uname

return fn(*args, **kwargs)

finally:

sys.modules.clear()

sys.modules.update(current_modules)

os.uname = current_uname

sys.meta_path[:] = current_meta_path

return Inner

开发者ID:elsigh,项目名称:browserscope,代码行数:24,

示例9: register_assert_rewrite

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def register_assert_rewrite(*names):

"""Register one or more module names to be rewritten on import.

This function will make sure that this module or all modules inside

the package will get their assert statements rewritten.

Thus you should make sure to call this before the module is

actually imported, usually in your __init__.py if you are a plugin

using a package.

:raise TypeError: if the given module names are not strings.

"""

for name in names:

if not isinstance(name, str):

msg = "expected module names as *args, got {0} instead"

raise TypeError(msg.format(repr(names)))

for hook in sys.meta_path:

if isinstance(hook, rewrite.AssertionRewritingHook):

importhook = hook

break

else:

importhook = DummyRewriteHook()

importhook.mark_rewrite(*names)

开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:24,

示例10: _add_git_repo

​点赞 6

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def _add_git_repo(url_builder, username=None, repo=None, module=None, branch=None, commit=None, **kw):

'''

Function that creates and adds to the 'sys.meta_path' an HttpImporter object equipped with a URL of a Online Git server.

The 'url_builder' parameter is a function that accepts the username, repo and branch/commit, and creates a HTTP/S URL of a Git server. Compatible functions are '__create_github_url', '__create_bitbucket_url'.

The 'username' parameter defines the Github username which is the repository's owner.

The 'repo' parameter defines the name of the repo that contains the modules/packages to be imported.

The 'module' parameter is optional and is a list containing the modules/packages that are available in the chosen Github repository.

If it is not provided, it defaults to the repositories name, as it is common that the a Python repository at "github.com/someuser/somereponame" contains a module/package of "somereponame".

The 'branch' and 'commit' parameters cannot be both populated at the same call. They specify the branch (last commit) or specific commit, that should be served.

'''

if username == None or repo == None:

raise Error("'username' and 'repo' parameters cannot be None")

if commit and branch:

raise Error("'branch' and 'commit' parameters cannot be both set!")

if commit:

branch = commit

if not branch:

branch = 'master'

if not module:

module = repo

if type(module) == str:

module = [module]

url = url_builder(username, repo, branch, **kw)

return add_remote_repo(module, url)

开发者ID:operatorequals,项目名称:httpimport,代码行数:27,

示例11: invalidate_caches

​点赞 5

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def invalidate_caches():

"""Call the invalidate_caches() method on all meta path finders stored in

sys.meta_path (where implemented)."""

for finder in sys.meta_path:

if hasattr(finder, 'invalidate_caches'):

finder.invalidate_caches()

开发者ID:war-and-code,项目名称:jawfish,代码行数:8,

示例12: _unload_pkg_resources

​点赞 5

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def _unload_pkg_resources():

sys.meta_path = [

importer

for importer in sys.meta_path

if importer.__class__.__module__ != 'pkg_resources.extern'

]

del_modules = [

name for name in sys.modules

if name.startswith('pkg_resources')

]

for mod_name in del_modules:

del sys.modules[mod_name]

开发者ID:aimuch,项目名称:iAI,代码行数:14,

示例13: install_hooks

​点赞 5

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def install_hooks(include_paths=(), exclude_paths=()):

if isinstance(include_paths, str):

include_paths = (include_paths,)

if isinstance(exclude_paths, str):

exclude_paths = (exclude_paths,)

assert len(include_paths) + len(exclude_paths) > 0, 'Pass at least one argument'

_hook.include(include_paths)

_hook.exclude(exclude_paths)

# _hook.debug = debug

enable = sys.version_info[0] >= 3 # enabled for all 3.x

if enable and _hook not in sys.meta_path:

sys.meta_path.insert(0, _hook) # insert at beginning. This could be made a parameter

# We could return the hook when there are ways of configuring it

#return _hook

开发者ID:remg427,项目名称:misp42splunk,代码行数:17,

示例14: remove_hooks

​点赞 5

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def remove_hooks():

if _hook in sys.meta_path:

sys.meta_path.remove(_hook)

开发者ID:remg427,项目名称:misp42splunk,代码行数:5,

示例15: detect_hooks

​点赞 5

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def detect_hooks():

"""

Returns True if the import hooks are installed, False if not.

"""

return _hook in sys.meta_path

# present = any([hasattr(hook, 'PY2FIXER') for hook in sys.meta_path])

# return present

开发者ID:remg427,项目名称:misp42splunk,代码行数:9,

示例16: _common_post_process

​点赞 5

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def _common_post_process(args):

# TODO(iannucci): We should always do logging.basicConfig() (probably with

# logging.WARNING), even if no verbose is passed. However we need to be

# careful as this could cause issues with spurious/unexpected output.

# Once the recipe engine is on native build.proto, this should be safe to

# do.

if args.verbose > 0:

logging.basicConfig()

logging.getLogger().setLevel(logging.INFO)

if args.verbose > 1:

logging.getLogger().setLevel(logging.DEBUG)

else:

# Prevent spurious "No handlers could be found for ..." stderr messages.

# Once we always set a basicConfig (per TODO above), this can go away as

# well.

logging.root.manager.emittedNoHandlerWarning = True

args.recipe_deps = RecipeDeps.create(

args.main_repo_path,

args.repo_override,

args.proto_override,

)

_check_recipes_cfg_consistency(args.recipe_deps)

# Allows:

# import RECIPE_MODULES.repo_name.module_name.submodule

sys.meta_path = [RecipeModuleImporter(args.recipe_deps)] + sys.meta_path

_cleanup_pyc(args.recipe_deps)

# Remove flags that subcommands shouldn't use; everything from this point on

# should ONLY use args.recipe_deps.

del args.main_repo_path

del args.verbose

del args.repo_override

开发者ID:luci,项目名称:recipes-py,代码行数:38,

示例17: unmount

​点赞 5

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def unmount(self):

pathname = os.path.abspath(os.path.join(self.dirname, self.filename))

if pathname not in sys.path:

logger.debug('%s not in path', pathname)

else:

sys.path.remove(pathname)

if pathname in _hook.impure_wheels:

_hook.remove(pathname)

if not _hook.impure_wheels:

if _hook in sys.meta_path:

sys.meta_path.remove(_hook)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,

示例18: setUp

​点赞 5

# 需要导入模块: import sys [as 别名]

# 或者: from sys import meta_path [as 别名]

def setUp(self):

super(SandboxTest, self).setUp()

self.mox = mox.Mox()

self.old_path = sys.path

self.old_meta_path = sys.meta_path

self.old_library_format_string = sandbox._THIRD_PARTY_LIBRARY_FORMAT_STRING

self.config = runtime_config_pb2.Config()

self.app_root = 'test/app/root'

self.config.application_root = self.app_root

self.config.app_id = 'app'

self.config.version_id = '1'

self.builtins = __builtin__.__dict__.copy()

self.modules = sys.modules.copy()

开发者ID:elsigh,项目名称:browserscope,代码行数:15,

注:本文中的sys.meta_path方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

python renamer_Python sys.meta_path方法代码示例相关推荐

  1. python paperclip_Python pyplot.sca方法代码示例

    本文整理汇总了Python中matplotlib.pyplot.sca方法的典型用法代码示例.如果您正苦于以下问题:Python pyplot.sca方法的具体用法?Python pyplot.sca ...

  2. python fonttool_Python wx.Font方法代码示例

    本文整理汇总了Python中wx.Font方法的典型用法代码示例.如果您正苦于以下问题:Python wx.Font方法的具体用法?Python wx.Font怎么用?Python wx.Font使用 ...

  3. python pool_Python pool.Pool方法代码示例

    本文整理汇总了Python中multiprocessing.pool.Pool方法的典型用法代码示例.如果您正苦于以下问题:Python pool.Pool方法的具体用法?Python pool.Po ...

  4. python dateformatter_Python dates.DateFormatter方法代码示例

    本文整理汇总了Python中matplotlib.dates.DateFormatter方法的典型用法代码示例.如果您正苦于以下问题:Python dates.DateFormatter方法的具体用法 ...

  5. python res_Python models.resnet152方法代码示例

    本文整理汇总了Python中torchvision.models.resnet152方法的典型用法代码示例.如果您正苦于以下问题:Python models.resnet152方法的具体用法?Pyth ...

  6. python dropout_Python slim.dropout方法代码示例

    本文整理汇总了Python中tensorflow.contrib.slim.dropout方法的典型用法代码示例.如果您正苦于以下问题:Python slim.dropout方法的具体用法?Pytho ...

  7. python batch_size_Python config.batch_size方法代码示例

    本文整理汇总了Python中config.batch_size方法的典型用法代码示例.如果您正苦于以下问题:Python config.batch_size方法的具体用法?Python config. ...

  8. python nextpow2_Python signal.hann方法代码示例

    本文整理汇总了Python中scipy.signal.hann方法的典型用法代码示例.如果您正苦于以下问题:Python signal.hann方法的具体用法?Python signal.hann怎么 ...

  9. python colormap_Python colors.LinearSegmentedColormap方法代码示例

    本文整理汇总了Python中matplotlib.colors.LinearSegmentedColormap方法的典型用法代码示例.如果您正苦于以下问题:Python colors.LinearSe ...

最新文章

  1. 新手熊猫烧香学习笔记
  2. (二)、MariaDB、Apache软件安装
  3. 解决django关于图片无法显示的问题
  4. python与人工智能编程-五大人工智能流行编程语言对比,只要学会一种绝对不亏!...
  5. 强网杯2019 Copperstudy
  6. Tr A(矩阵快速幂)
  7. 2014年5月第二个周末总结--保守自己的心
  8. 再谈mysql数据库之索引,联合索引,覆盖索引
  9. 一打卡作弊软件CEO被判5年6个月,网友:这也太...
  10. Python爬取EF每日英语资源
  11. 手机重装android系统,安卓手机系统怎样重装
  12. 机器学习 (六): Sigmoid 公式推导和理解
  13. python如何判断用户的电话属于移动、联通、还是电信的
  14. 国内外大厂扑向AR-HUD,但抵达“智能汽车终局”仍隔数层纱
  15. qt下开发mqtt的访问程序
  16. 图像相似度计算-kmeans聚类
  17. java 时间轮算法_时间轮算法解析(Netty HashedWheelTimer源码解读)
  18. mb63.nte.ios.html,2019苹果无限魔力鸟
  19. 强大的W32Dasm反汇编工具使用教程
  20. Atom编辑器活跃用户突破一百万

热门文章

  1. 分享8款令人惊叹的HTML5 Canvas动画特效
  2. 又一经典音乐,不说了,你懂得
  3. 计算机毕业的人有很多不从事IT行业
  4. 搭建个人私有服务器(四)—— 宝塔面板添加网站
  5. 2021朔城区一中高考成绩查询,青春有志逐梦远行—朔城区一中2021届高三毕业典礼暨高考壮行大会...
  6. 大数据是什么?发展前景怎么样
  7. 艾永亮:分析儿童智能手表市场,为什么品牌只有小天才和其他?
  8. signature=60f8eeca8788f5db0f874e2b9c785ab7,SIGNATURE EXPLORATION UPDATES FRIO SANDS TARGET IN TEXAS.
  9. 使用Oracle VM VirtualBox完成Linux环境搭建openEuler
  10. oracle标量子查询 外层,Oracle标量子查询