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


Python ntpath.splitunc方法代碼示例

本文整理匯總了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')) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:22,代碼來源:test_ntpath.py

示例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')) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:21,代碼來源:test_ntpath.py

示例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')) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:24,代碼來源:test_ntpath.py

示例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')) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:7,代碼來源:test_ntpath.py

示例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) 
開發者ID:kurobeats,項目名稱:fimap,代碼行數:30,代碼來源:baseClass.py


注:本文中的ntpath.splitunc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。