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


Python nt._getvolumepathname方法代码示例

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


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

示例1: ismount

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getvolumepathname [as 别名]
def ismount(path):
    """Test whether a path is a mount point (a drive root, the root of a
    share, or a mounted volume)"""
    seps = _get_bothseps(path)
    path = abspath(path)
    root, rest = splitdrive(path)
    if root and root[0] in seps:
        return (not rest) or (rest in seps)
    if rest in seps:
        return True

    if _getvolumepathname:
        return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps)
    else:
        return False


# Expand paths beginning with '~' or '~user'.
# '~' means $HOME; '~user' means that user's home directory.
# If the path doesn't begin with '~', or if the user or $HOME is unknown,
# the path is returned unchanged (leaving error reporting to whatever
# function is called with the expanded path as argument).
# See also module 'glob' for expansion of *, ? and [...] in pathnames.
# (A function should also be defined to do full *sh-style environment
# variable expansion.) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:27,代码来源:ntpath.py

示例2: ismount

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getvolumepathname [as 别名]
def ismount(path):
    """Test whether a path is a mount point (a drive root, the root of a
    share, or a mounted volume)"""
    path = os.fspath(path)
    seps = _get_bothseps(path)
    path = abspath(path)
    root, rest = splitdrive(path)
    if root and root[0] in seps:
        return (not rest) or (rest in seps)
    if rest in seps:
        return True

    if _getvolumepathname:
        return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps)
    else:
        return False


# Expand paths beginning with '~' or '~user'.
# '~' means $HOME; '~user' means that user's home directory.
# If the path doesn't begin with '~', or if the user or $HOME is unknown,
# the path is returned unchanged (leaving error reporting to whatever
# function is called with the expanded path as argument).
# See also module 'glob' for expansion of *, ? and [...] in pathnames.
# (A function should also be defined to do full *sh-style environment
# variable expansion.) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:28,代码来源:ntpath.py

示例3: test_nt_helpers

# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getvolumepathname [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._getvolumepathname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。