pathlib2.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:pipenv 作者: pypa 项目源码 文件源码
def resolve(self, path, strict=False):
        s = str(path)
        if not s:
            return os.getcwd()
        previous_s = None
        if _getfinalpathname is not None:
            if strict:
                return self._ext_to_normal(_getfinalpathname(s))
            else:
                # End of the path after the first one not found
                tail_parts = []
                while True:
                    try:
                        s = self._ext_to_normal(_getfinalpathname(s))
                    except FileNotFoundError:
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号