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


Python util.convert_path方法代碼示例

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


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

示例1: copy_scripts

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def copy_scripts(self):
        _build_scripts.copy_scripts(self)

        if "install" in self.distribution.command_obj:
            iobj = self.distribution.command_obj["install"]
            libDir = iobj.install_lib

            if iobj.root:
                libDir = libDir[len(iobj.root):]

            script = convert_path("bin/trelby")
            outfile = os.path.join(self.build_dir, os.path.basename(script))

            # abuse fileinput to replace a line in bin/trelby
            for line in fileinput.input(outfile, inplace = 1):
                if """sys.path.insert(0, "src")""" in line:
                    line = """sys.path.insert(0, "%s/src")""" % libDir

                print line, 
開發者ID:trelby,項目名稱:trelby,代碼行數:21,代碼來源:setup.py

示例2: find

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def find(cls, where='.', exclude=(), include=('*',)):
        """Return a list all Python packages found within directory 'where'

        'where' should be supplied as a "cross-platform" (i.e. URL-style)
        path; it will be converted to the appropriate local path syntax.
        'exclude' is a sequence of package names to exclude; '*' can be used
        as a wildcard in the names, such that 'foo.*' will exclude all
        subpackages of 'foo' (but not 'foo' itself).

        'include' is a sequence of package names to include.  If it's
        specified, only the named packages will be included.  If it's not
        specified, all found packages will be included.  'include' can contain
        shell style wildcard patterns just like 'exclude'.

        The list of included packages is built up first and then any
        explicitly excluded packages are removed from it.
        """
        out = cls._find_packages_iter(convert_path(where))
        out = cls.require_parents(out)
        includes = cls._build_filter(*include)
        excludes = cls._build_filter('ez_setup', '*__pycache__', *exclude)
        out = filter(includes, out)
        out = filterfalse(excludes, out)
        return list(out) 
開發者ID:jpush,項目名稱:jbox,代碼行數:26,代碼來源:__init__.py

示例3: install_egg_scripts

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def install_egg_scripts(self, dist):
        if dist is not self.dist:
            # Installing a dependency, so fall back to normal behavior
            return easy_install.install_egg_scripts(self, dist)

        # create wrapper scripts in the script dir, pointing to dist.scripts

        # new-style...
        self.install_wrapper_scripts(dist)

        # ...and old-style
        for script_name in self.distribution.scripts or []:
            script_path = os.path.abspath(convert_path(script_name))
            script_name = os.path.basename(script_path)
            with io.open(script_path) as strm:
                script_text = strm.read()
            self.install_script(dist, script_name, script_text, script_path) 
開發者ID:jpush,項目名稱:jbox,代碼行數:19,代碼來源:develop.py

示例4: config_file

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def config_file(kind="local"):
    """Get the filename of the distutils, local, global, or per-user config

    `kind` must be one of "local", "global", or "user"
    """
    if kind == 'local':
        return 'setup.cfg'
    if kind == 'global':
        return os.path.join(
            os.path.dirname(distutils.__file__), 'distutils.cfg'
        )
    if kind == 'user':
        dot = os.name == 'posix' and '.' or ''
        return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot))
    raise ValueError(
        "config_file() type must be 'local', 'global', or 'user'", kind
    ) 
開發者ID:jpush,項目名稱:jbox,代碼行數:19,代碼來源:setopt.py

示例5: exclude_data_files

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def exclude_data_files(self, package, src_dir, files):
        """Filter filenames for package's data files in 'src_dir'"""
        globs = (
            self.exclude_package_data.get('', [])
            + self.exclude_package_data.get(package, [])
        )
        bad = set(
            item
            for pattern in globs
            for item in fnmatch.filter(
                files,
                os.path.join(src_dir, convert_path(pattern)),
            )
        )
        seen = collections.defaultdict(itertools.count)
        return [
            fn
            for fn in files
            if fn not in bad
            # ditch dupes
            and not next(seen[fn])
        ] 
開發者ID:jpush,項目名稱:jbox,代碼行數:24,代碼來源:build_py.py

示例6: _add_defaults_data_files

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def _add_defaults_data_files(self):
        # getting distribution.data_files
        if self.distribution.has_data_files():
            for item in self.distribution.data_files:
                if isinstance(item, str):
                    # plain file
                    item = convert_path(item)
                    if os.path.isfile(item):
                        self.filelist.append(item)
                else:
                    # a (dirname, filenames) tuple
                    dirname, filenames = item
                    for f in filenames:
                        f = convert_path(f)
                        if os.path.isfile(f):
                            self.filelist.append(f) 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:18,代碼來源:py36compat.py

示例7: finalize_options

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def finalize_options(self):
        self.set_undefined_options('build',
                                   ('build_lib', 'build_lib'),
                                   ('force', 'force'))

        # Get the distribution options that are aliases for build_py
        # options -- list of packages and list of modules.
        self.packages = self.distribution.packages
        self.py_modules = self.distribution.py_modules
        self.package_data = self.distribution.package_data
        self.package_dir = {}
        if self.distribution.package_dir:
            for name, path in self.distribution.package_dir.items():
                self.package_dir[name] = convert_path(path)
        self.data_files = self.get_data_files()

        # Ick, copied straight from install_lib.py (fancy_getopt needs a
        # type system!  Hell, *everything* needs a type system!!!)
        if not isinstance(self.optimize, int):
            try:
                self.optimize = int(self.optimize)
                assert 0 <= self.optimize <= 2
            except (ValueError, AssertionError):
                raise DistutilsOptionError("optimize must be 0, 1, or 2") 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:26,代碼來源:build_py.py

示例8: install_egg_scripts

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def install_egg_scripts(self, dist):
        if dist is not self.dist:
            # Installing a dependency, so fall back to normal behavior
            return easy_install.install_egg_scripts(self,dist)

        # create wrapper scripts in the script dir, pointing to dist.scripts

        # new-style...
        self.install_wrapper_scripts(dist)

        # ...and old-style
        for script_name in self.distribution.scripts or []:
            script_path = os.path.abspath(convert_path(script_name))
            script_name = os.path.basename(script_path)
            f = open(script_path,'rU')
            script_text = f.read()
            f.close()
            self.install_script(dist, script_name, script_text, script_path) 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:20,代碼來源:develop.py

示例9: config_file

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def config_file(kind="local"):
    """Get the filename of the distutils, local, global, or per-user config

    `kind` must be one of "local", "global", or "user"
    """
    if kind=='local':
        return 'setup.cfg'
    if kind=='global':
        return os.path.join(
            os.path.dirname(distutils.__file__),'distutils.cfg'
        )
    if kind=='user':
        dot = os.name=='posix' and '.' or ''
        return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot))
    raise ValueError(
        "config_file() type must be 'local', 'global', or 'user'", kind
    ) 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:19,代碼來源:setopt.py

示例10: exclude_data_files

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def exclude_data_files(self, package, src_dir, files):
        """Filter filenames for package's data files in 'src_dir'"""
        globs = (self.exclude_package_data.get('', [])
                 + self.exclude_package_data.get(package, []))
        bad = []
        for pattern in globs:
            bad.extend(
                fnmatch.filter(
                    files, os.path.join(src_dir, convert_path(pattern))
                )
            )
        bad = dict.fromkeys(bad)
        seen = {}
        return [
            f for f in files if f not in bad
                and f not in seen and seen.setdefault(f,1)  # ditch dupes
        ] 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:19,代碼來源:build_py.py

示例11: _get_platform_patterns

# 需要導入模塊: from distutils import util [as 別名]
# 或者: from distutils.util import convert_path [as 別名]
def _get_platform_patterns(spec, package, src_dir):
        """
        yield platform-specific path patterns (suitable for glob
        or fn_match) from a glob-based spec (such as
        self.package_data or self.exclude_package_data)
        matching package in src_dir.
        """
        raw_patterns = itertools.chain(
            spec.get('', []),
            spec.get(package, []),
        )
        return (
            # Each pattern has to be converted to a platform-specific path
            os.path.join(src_dir, convert_path(pattern))
            for pattern in raw_patterns
        )


# from Python docs 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:21,代碼來源:build_py.py


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