當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。