当前位置: 首页>>代码示例>>Python>>正文


Python path.samefile方法代码示例

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


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

示例1: invalid_virtualenv_reason

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def invalid_virtualenv_reason(venv_path, source_python, destination_python, options):
    try:
        orig_path = get_original_path(venv_path)
    except CalledProcessError:
        return 'could not inspect metadata'
    if not samefile(orig_path, venv_path):
        return 'virtualenv moved %s -> %s' % (timid_relpath(orig_path), timid_relpath(venv_path))
    elif has_system_site_packages(destination_python) != options.system_site_packages:
        return 'system-site-packages changed, to %s' % options.system_site_packages

    if source_python is None:
        return
    destination_version = get_python_version(destination_python)
    source_version = get_python_version(source_python)
    if source_version != destination_version:
        return 'python version changed %s -> %s' % (destination_version, source_version) 
开发者ID:edmundmok,项目名称:mealpy,代码行数:18,代码来源:venv_update.py

示例2: maybe_relative_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def maybe_relative_path(path):
    if not os.path.isabs(path):
        return path      # already relative
    dir = path
    names = []
    while True:
        prevdir = dir
        dir, name = os.path.split(prevdir)
        if dir == prevdir or not dir:
            return path     # failed to make it relative
        names.append(name)
        try:
            if samefile(dir, os.curdir):
                names.reverse()
                return os.path.join(*names)
        except OSError:
            pass

# ____________________________________________________________ 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:21,代码来源:ffiplatform.py

示例3: samefile

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def samefile(self, f1, f2):
        """
        Determine if the two given filenames point to the same file
        within the plugin folder.

        :param f1: Name of the first file to test.
        :type f1: str

        :param f2: Name of the second file to test.
        :type f2: str

        :returns: True if the files are the same, False otherwise.
        :rtype: bool
        """

        # Sanitize the filenames.
        f1 = self.__sanitize(f1)
        f2 = self.__sanitize(f2)

        # Test the filenames.
        return path.samefile(f1, f2)


    #-------------------------------------------------------------------------- 
开发者ID:blackye,项目名称:luscan-devel,代码行数:26,代码来源:localfile.py

示例4: __eq__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def __eq__(self, other):
        """
        Two dumpreader are equal, if they represent the same dump.

        Assuming both dumpidentifier are paths to the dumpfiles, simple string comparison
        may give a "False",
        although they both point to the same file:
        * ./path/to/file
        * path/to/file
        * /absolute/path/to/file

        Therefore this functions tries to interpret the dumpidentifier as paths/to/files.
        In case this is successful and both files exist,
        the function checks if they point to the same file.
        """
        import os.path as osp
        s1 = str(self.dumpidentifier)
        s2 = str(other.dumpidentifier)
        if osp.isfile(s1) and osp.isfile(s2):
            # osp.samefile available under Windows since python 3.2
            return osp.samefile(s1, s2)
        else:
            # seems to be something else than a path to a file
            return self.dumpidentifier == other.dumpidentifier 
开发者ID:skuschel,项目名称:postpic,代码行数:26,代码来源:datareader.py

示例5: _openResultingFileForEdit

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def _openResultingFileForEdit(self):
        """
        Opens the resulting conf file for editing so the user can tweak and
        test
        """
        self._logger.debug("Opening resulting file for edition")
        # If the current buffer is already pointing to the project file, reuse
        # it
        if not p.exists(vim.current.buffer.name) or p.samefile(
            vim.current.buffer.name, self._project_file
        ):
            vim.command("edit! %s" % self._project_file)
        else:
            vim.command("vsplit %s" % self._project_file)

        vim.current.buffer.vars["is_vimhdl_generated"] = True
        vim.command("set filetype=vimhdl") 
开发者ID:suoto,项目名称:vim-hdl,代码行数:19,代码来源:config_gen_wrapper.py

示例6: invalid_virtualenv_reason

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def invalid_virtualenv_reason(venv_path, source_python, destination_python, options):
    try:
        orig_path = get_original_path(venv_path)
    except CalledProcessError:
        return 'could not inspect metadata'
    if not samefile(orig_path, venv_path):
        return 'virtualenv moved {} -> {}'.format(timid_relpath(orig_path), timid_relpath(venv_path))
    elif has_system_site_packages(destination_python) != options.system_site_packages:
        return 'system-site-packages changed, to %s' % options.system_site_packages

    if source_python is None:
        return
    destination_version = get_python_version(destination_python)
    source_version = get_python_version(source_python)
    if source_version != destination_version:
        return 'python version changed {} -> {}'.format(destination_version, source_version) 
开发者ID:Yelp,项目名称:venv-update,代码行数:18,代码来源:venv_update.py

示例7: samefile

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def samefile(file1, file2):
    if not exists(file1) or not exists(file2):
        return False
    else:
        from os.path import samefile
        return samefile(file1, file2) 
开发者ID:edmundmok,项目名称:mealpy,代码行数:8,代码来源:venv_update.py

示例8: samefile

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def samefile(f1, f2):
        return os.path.abspath(f1) == os.path.abspath(f2) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:4,代码来源:ffiplatform.py

示例9: search_files_upward

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def search_files_upward(start_path=None):
    "Search for requirements.txt, setup.py or Pipfile upward"
    if not start_path:
        start_path = op.abspath(op.curdir)
    if any(
            op.exists(op.join(start_path, filename))
            for filename in ('requirements.txt', 'setup.py', 'Pipfile')
    ):
        return start_path
    up_path = op.abspath(op.join(start_path, '..'))
    if op.samefile(start_path, up_path):
        return None
    return search_files_upward(start_path=up_path) 
开发者ID:Deepwalker,项目名称:pundler,代码行数:15,代码来源:pundle.py

示例10: from_potential_worktree

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def from_potential_worktree(cls, wd):
        real_wd, _, ret = do_ex("git rev-parse --show-toplevel", wd)
        if ret:
            return
        trace("real root", real_wd)
        if not samefile(real_wd, wd):
            return

        return cls(real_wd) 
开发者ID:pypa,项目名称:setuptools_scm,代码行数:11,代码来源:git.py

示例11: from_potential_worktree

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def from_potential_worktree(cls, wd):
        real_wd, _, ret = do_ex('git rev-parse --show-toplevel', wd)
        if ret:
            return
        trace('real root', real_wd)
        if not samefile(real_wd, wd):
            return

        return cls(real_wd) 
开发者ID:thomaxxl,项目名称:safrs,代码行数:11,代码来源:git.py

示例12: samefile

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import samefile [as 别名]
def samefile(f1, f2):
            """Test whether two pathnames reference the same actual file or
            directory This is determined by the device number and i-node number
            and raises an exception if an os.stat() call on either pathname
            fails."""
            s1 = os.stat(f1)
            s2 = os.stat(f2)
            return samestat(s1, s2) 
开发者ID:pypa,项目名称:pipenv,代码行数:10,代码来源:compat.py


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