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


Python nt._getfinalpathname方法代码示例

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


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

示例1: resolve

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfinalpathname [as 别名]
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:
                tail_parts = []  # End of the path after the first one not found
                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 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:25,代码来源:pathlib.py

示例2: resolve

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfinalpathname [as 别名]
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 
开发者ID:eirannejad,项目名称:pyRevit,代码行数:26,代码来源:__init__.py

示例3: resolve

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfinalpathname [as 别名]
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 = []

                def _try_func():
                    result[0] = self._ext_to_normal(_getfinalpathname(s))
                    # if there was no exception, set flag to 0
                    result[1] = 0

                def _exc_func(exc):
                    pass

                while True:
                    result = [None, 1]
                    _try_except_filenotfounderror(_try_func, _exc_func)
                    if result[1] == 1:  # file not found exception raised
                        previous_s = s
                        s, tail = os.path.split(s)
                        tail_parts.append(tail)
                        if previous_s == s:
                            return path
                    else:
                        s = result[0]
                        return os.path.join(s, *reversed(tail_parts))
        # Means fallback on absolute
        return None 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:36,代码来源:__init__.py

示例4: _getfinalpathname

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfinalpathname [as 别名]
def _getfinalpathname(f):
        return normcase(abspath(f)) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:4,代码来源:ntpath.py

示例5: resolve

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfinalpathname [as 别名]
def resolve(self, path):
        s = str(path)
        if not s:
            return os.getcwd()
        if _getfinalpathname is not None:
            return self._ext_to_normal(_getfinalpathname(s))
        # Means fallback on absolute
        return None 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:pathlib.py

示例6: test_nt_helpers

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getfinalpathname [as 别名]
def test_nt_helpers(self):
        # Trivial validation that the helpers do not break, and support both
        # unicode and bytes (UTF-8) paths

        drive, path = ntpath.splitdrive(sys.executable)
        drive = drive.rstrip(ntpath.sep) + ntpath.sep
        self.assertEqual(drive, nt._getvolumepathname(sys.executable))
        self.assertEqual(drive.encode(),
                         nt._getvolumepathname(sys.executable.encode()))

        cap, free = nt._getdiskusage(sys.exec_prefix)
        self.assertGreater(cap, 0)
        self.assertGreater(free, 0)
        b_cap, b_free = nt._getdiskusage(sys.exec_prefix.encode())
        # Free space may change, so only test the capacity is equal
        self.assertEqual(b_cap, cap)
        self.assertGreater(b_free, 0)

        for path in [sys.prefix, sys.executable]:
            final_path = nt._getfinalpathname(path)
            self.assertIsInstance(final_path, str)
            self.assertGreater(len(final_path), 0)

            b_final_path = nt._getfinalpathname(path.encode())
            self.assertIsInstance(b_final_path, bytes)
            self.assertGreater(len(b_final_path), 0) 
开发者ID:bkerler,项目名称:android_universal,代码行数:28,代码来源:test_ntpath.py


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