本文整理汇总了Python中ntpath.splitunc方法的典型用法代码示例。如果您正苦于以下问题:Python ntpath.splitunc方法的具体用法?Python ntpath.splitunc怎么用?Python ntpath.splitunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ntpath
的用法示例。
在下文中一共展示了ntpath.splitunc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_splitunc
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import splitunc [as 别名]
def test_splitunc(self):
tester('ntpath.splitunc("c:\\foo\\bar")',
('', 'c:\\foo\\bar'))
tester('ntpath.splitunc("c:/foo/bar")',
('', 'c:/foo/bar'))
tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")',
('\\\\conky\\mountpoint', '\\foo\\bar'))
tester('ntpath.splitunc("//conky/mountpoint/foo/bar")',
('//conky/mountpoint', '/foo/bar'))
tester('ntpath.splitunc("\\\\\\conky\\mountpoint\\foo\\bar")',
('', '\\\\\\conky\\mountpoint\\foo\\bar'))
tester('ntpath.splitunc("///conky/mountpoint/foo/bar")',
('', '///conky/mountpoint/foo/bar'))
tester('ntpath.splitunc("\\\\conky\\\\mountpoint\\foo\\bar")',
('', '\\\\conky\\\\mountpoint\\foo\\bar'))
tester('ntpath.splitunc("//conky//mountpoint/foo/bar")',
('', '//conky//mountpoint/foo/bar'))
if test_support.have_unicode:
self.assertEqual(ntpath.splitunc(u'//conky/MOUNTPO%cNT/foo/bar' % 0x0130),
(u'//conky/MOUNTPO%cNT' % 0x0130, u'/foo/bar'))
示例2: test_splitunc
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import splitunc [as 别名]
def test_splitunc(self):
tester('ntpath.splitunc("c:\\foo\\bar")',
('', 'c:\\foo\\bar'))
tester('ntpath.splitunc("c:/foo/bar")',
('', 'c:/foo/bar'))
tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")',
('\\\\conky\\mountpoint', '\\foo\\bar'))
tester('ntpath.splitunc("//conky/mountpoint/foo/bar")',
('//conky/mountpoint', '/foo/bar'))
tester('ntpath.splitunc("\\\\\\conky\\mountpoint\\foo\\bar")',
('', '\\\\\\conky\\mountpoint\\foo\\bar'))
tester('ntpath.splitunc("///conky/mountpoint/foo/bar")',
('', '///conky/mountpoint/foo/bar'))
tester('ntpath.splitunc("\\\\conky\\\\mountpoint\\foo\\bar")',
('', '\\\\conky\\\\mountpoint\\foo\\bar'))
tester('ntpath.splitunc("//conky//mountpoint/foo/bar")',
('', '//conky//mountpoint/foo/bar'))
self.assertEqual(ntpath.splitunc(u'//conky/MOUNTPO\u0130NT/foo/bar'),
(u'//conky/MOUNTPO\u0130NT', u'/foo/bar'))
示例3: test_splitunc
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import splitunc [as 别名]
def test_splitunc(self):
with self.assertWarns(DeprecationWarning):
ntpath.splitunc('')
with support.check_warnings(('', DeprecationWarning)):
tester('ntpath.splitunc("c:\\foo\\bar")',
('', 'c:\\foo\\bar'))
tester('ntpath.splitunc("c:/foo/bar")',
('', 'c:/foo/bar'))
tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")',
('\\\\conky\\mountpoint', '\\foo\\bar'))
tester('ntpath.splitunc("//conky/mountpoint/foo/bar")',
('//conky/mountpoint', '/foo/bar'))
tester('ntpath.splitunc("\\\\\\conky\\mountpoint\\foo\\bar")',
('', '\\\\\\conky\\mountpoint\\foo\\bar'))
tester('ntpath.splitunc("///conky/mountpoint/foo/bar")',
('', '///conky/mountpoint/foo/bar'))
tester('ntpath.splitunc("\\\\conky\\\\mountpoint\\foo\\bar")',
('', '\\\\conky\\\\mountpoint\\foo\\bar'))
tester('ntpath.splitunc("//conky//mountpoint/foo/bar")',
('', '//conky//mountpoint/foo/bar'))
self.assertEqual(ntpath.splitunc('//conky/MOUNTPOİNT/foo/bar'),
('//conky/MOUNTPOİNT', '/foo/bar'))
示例4: test_splitunc
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import splitunc [as 别名]
def test_splitunc(self):
tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")',
('\\\\conky\\mountpoint', '\\foo\\bar'))
tester('ntpath.splitunc("//conky/mountpoint/foo/bar")',
('//conky/mountpoint', '/foo/bar'))
示例5: relpath_win
# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import splitunc [as 别名]
def relpath_win(self, path, start="."):
"""Return a relative version of a path"""
sep="\\"
if not path:
raise ValueError("no path specified")
start_list = ntpath.abspath(start).split(sep)
path_list = ntpath.abspath(path).split(sep)
if start_list[0].lower() != path_list[0].lower():
unc_path, rest = ntpath.splitunc(path)
unc_start, rest = ntpath.splitunc(start)
if bool(unc_path) ^ bool(unc_start):
raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)"
% (path, start))
else:
raise ValueError("path is on drive %s, start on drive %s"
% (path_list[0], start_list[0]))
# Work out how much of the filepath is shared by start and path.
for i in range(min(len(start_list), len(path_list))):
if start_list[i].lower() != path_list[i].lower():
break
else:
i += 1
rel_list = ['..'] * (len(start_list)-i) + path_list[i:]
if not rel_list:
return "."
return ntpath.join(*rel_list)