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