當前位置: 首頁>>代碼示例>>Python>>正文


Python nt._getdiskusage方法代碼示例

本文整理匯總了Python中nt._getdiskusage方法的典型用法代碼示例。如果您正苦於以下問題:Python nt._getdiskusage方法的具體用法?Python nt._getdiskusage怎麽用?Python nt._getdiskusage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nt的用法示例。


在下文中一共展示了nt._getdiskusage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: disk_usage

# 需要導入模塊: import nt [as 別名]
# 或者: from nt import _getdiskusage [as 別名]
def disk_usage(path):
        """Return disk usage statistics about the given path.

        Returned values is a named tuple with attributes 'total', 'used' and
        'free', which are the amount of total, used and free space, in bytes.
        """
        total, free = nt._getdiskusage(path)
        used = total - free
        return _ntuple_diskusage(total, used, free) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:11,代碼來源:shutil.py

示例2: test_nt_helpers

# 需要導入模塊: import nt [as 別名]
# 或者: from nt import _getdiskusage [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._getdiskusage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。