• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python site._init_pathinfo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中site._init_pathinfo函数的典型用法代码示例。如果您正苦于以下问题:Python _init_pathinfo函数的具体用法?Python _init_pathinfo怎么用?Python _init_pathinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_init_pathinfo

 def test_init_pathinfo(self):
     dir_set = site._init_pathinfo()
     for entry in [site.makepath(path)[1] for path in sys.path
                     if path and os.path.isdir(path)]:
         self.assertIn(entry, dir_set,
                       "%s from sys.path not found in set returned "
                       "by _init_pathinfo(): %s" % (entry, dir_set))
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:7,代码来源:test_site.py


示例2: _install_namespace_package

 def _install_namespace_package(self, tmp_sitedir):
     # Install our test namespace package in such a way that both py27 and
     # py36 can find it.
     from setuptools import namespaces
     installer = namespaces.Installer()
     class Distribution: namespace_packages = ['namespace_package']
     installer.distribution = Distribution()
     installer.target = os.path.join(tmp_sitedir, 'namespace_package.pth')
     installer.outputs = []
     installer.dry_run = False
     installer.install_namespaces()
     site.addsitedir(tmp_sitedir, known_paths=site._init_pathinfo())
开发者ID:kbusekist,项目名称:cloud-custodian,代码行数:12,代码来源:test_mu.py


示例3: addpackage

def addpackage(sitedir, name, known_paths, prepend_mode = False):
    effective_known_paths = \
        known_paths if known_paths is not None else _site._init_pathinfo()

    fullname = os.path.join(sitedir, name)

    # Figure out if we're dealing with a zip file.
    archive_path, pth_file = split_zip_path(fullname)
    archive = None
    if not archive_path:
        f = open(pth_file, mode)
    else:
        archive = zipfile.ZipFile(archive_path)
        f = archive.open(pth_file, "r")

    # Parse through the .pth file
    for n, line in enumerate(f):
        # Ignore comments
        if line.startswith(b"#"):
            continue

        try:
            # Execute any lines starting with import
            if line.startswith((b"import ", b"import\t")):
                exec(line)
            else:
                line = line.rstrip()
                dir, dircase = makepath(sitedir, line.decode('utf-8'))
                if not dircase in known_paths and exists(dir):
                    #Handy debug statement: print "added", dir
                    if prepend_mode:
                        sys.path.insert(0, dir)
                    else:
                        sys.path.append(dir)
                    effective_known_paths.add(dircase)
        except Exception:
            print("Error processing line {:d} of {}:\n".format(n + 1, fullname), file=sys.stderr)

            # Pretty print the exception info
            for record in traceback.format_exception(*sys.exc_info()):
                for line in record.splitlines():
                    print("  " + line, file=sys.stderr)

            print("\nRemainder of file ignored", file=sys.stderr)

            break

    f.close()
    if archive is not None:
        archive.close()

    return known_paths
开发者ID:Mondego,项目名称:pyreco,代码行数:52,代码来源:allPythonContent.py


示例4: swig_import_helper

 def swig_import_helper():
     from os.path import dirname, join
     import imp
     import site
     try:
         fp, pathname, description = imp.find_module('_graphviz', list(site._init_pathinfo()) +
             [dirname(__file__), join(dirname(__file__),'pyvizgraph')])
     except ImportError:
         import _graphviz
         return _graphviz
     if fp:
         try:
             _mod = imp.load_module('_graphviz', fp, pathname, description)
         finally:
             fp.close()
         return _mod
开发者ID:andreabedini,项目名称:pygraphviz,代码行数:16,代码来源:graphviz.py


示例5: section

    def section(self):

        stdlib_path = [sysconfig.get_path('stdlib')]

        site_path = sysconfig.get_path('purelib')

        # some stdlib modules have different paths inside a virtualenv
        if hasattr(sys, 'real_prefix'):
            import site

            stdlib_path.extend([p for p in site._init_pathinfo() if
                                re.match(sys.real_prefix, p)])

        try:

            fpath = self.module.__file__

        except AttributeError:
            # builtin, thus stdlib
            section = ModuleImporter.STDLIB

        else:

            if re.match(site_path, fpath):

                section = ModuleImporter.SITE

            elif [p for p in stdlib_path if re.match(p, fpath)]:

                section = ModuleImporter.STDLIB

            else:

                section = ModuleImporter.USER

        return section
开发者ID:MichaelCereda,项目名称:vimpy,代码行数:36,代码来源:util.py


示例6: addsitedir

def addsitedir(sitedir, known_paths = None, prepend_mode = False):
    # We need to return exactly what they gave as known_paths, so don't touch
    # it.
    effective_known_paths = \
        known_paths if known_paths is not None else _site._init_pathinfo()

    # Figure out what (if any) part of the path is a zip archive.
    archive_path, site_path = split_zip_path(sitedir)
    if not site_path.endswith("/"):
        site_path = site_path + "/"

    # If the user is not trying to add a directory in a zip file, just use
    # the standard function.
    if not archive_path:
        return old_addsitedir(sitedir, effective_known_paths)

    # Add the site directory itself
    if prepend_mode:
        sys.path.insert(0, sitedir)
    else:
        sys.path.append(sitedir)

    with closing(zipfile.ZipFile(archive_path, mode = "r")) as archive:
        # Go trhough everything in the archive...
        for i in archive.infolist():
            # and grab all the .pth files.
            if os.path.dirname(i.filename) == os.path.dirname(site_path) and \
                    i.filename.endswith(os.extsep + "pth"):
                addpackage(
                    os.path.join(archive_path, site_path),
                    os.path.basename(i.filename),
                    effective_known_paths,
                    prepend_mode = prepend_mode
                )

    return known_paths
开发者ID:Mondego,项目名称:pyreco,代码行数:36,代码来源:allPythonContent.py


示例7: get_sys_path

 def get_sys_path(self):
     for path in [os.path.join(p, 'site-packages') for p in site._init_pathinfo()
                  if p.startswith(sys.real_prefix)]:
         if os.path.isdir(path):
             return path
开发者ID:dbsr,项目名称:assortmentofsorts,代码行数:5,代码来源:system_environment.py


示例8: SublimeCodeIntelConfig

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import site

PYTHON_PATH = sys.executable
PYTHON_EXTRAS_PATH = site._init_pathinfo()


CONFIG_TEMPLATE = """{
    'Python': {
        'python': '%s',
        'pythonExtraPaths': %s
    }
}
"""


class SublimeCodeIntelConfig(object):
    """SublimeCodeIntelConfig"""
    config_path = '.codeintel'
    config_file = '.codeintel/config'
    config_text = ''

    def __init__(self):
        super(SublimeCodeIntelConfig, self).__init__()

    def format_config(self):
        self.config_text = CONFIG_TEMPLATE % (PYTHON_PATH,
                                              str(list(PYTHON_EXTRAS_PATH)))
开发者ID:yograterol,项目名称:config-sci,代码行数:31,代码来源:config_sci.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python site.addpackage函数代码示例发布时间:2022-05-27
下一篇:
Python io.import_from_yaml函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap