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


Python ntpath.sep方法代码示例

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


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

示例1: test_windows_colon

# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import sep [as 别名]
def test_windows_colon(self):
        import SimpleHTTPServer
        with test_support.swap_attr(SimpleHTTPServer.os, 'path', ntpath):
            path = self.handler.translate_path('c:c:c:foo/filename')
            path = path.replace(ntpath.sep, os.sep)
            self.assertEqual(path, self.translated)

            path = self.handler.translate_path('\\c:../filename')
            path = path.replace(ntpath.sep, os.sep)
            self.assertEqual(path, self.translated)

            path = self.handler.translate_path('c:\\c:..\\foo/filename')
            path = path.replace(ntpath.sep, os.sep)
            self.assertEqual(path, self.translated)

            path = self.handler.translate_path('c:c:foo\\c:c:bar/filename')
            path = path.replace(ntpath.sep, os.sep)
            self.assertEqual(path, self.translated) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_httpservers.py

示例2: test_windows_colon

# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import sep [as 别名]
def test_windows_colon(self):
        with support.swap_attr(server.os, 'path', ntpath):
            path = self.handler.translate_path('c:c:c:foo/filename')
            path = path.replace(ntpath.sep, os.sep)
            self.assertEqual(path, self.translated)

            path = self.handler.translate_path('\\c:../filename')
            path = path.replace(ntpath.sep, os.sep)
            self.assertEqual(path, self.translated)

            path = self.handler.translate_path('c:\\c:..\\foo/filename')
            path = path.replace(ntpath.sep, os.sep)
            self.assertEqual(path, self.translated)

            path = self.handler.translate_path('c:c:foo\\c:c:bar/filename')
            path = path.replace(ntpath.sep, os.sep)
            self.assertEqual(path, self.translated) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:19,代码来源:test_httpservers.py

示例3: to_os_native_path

# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import sep [as 别名]
def to_os_native_path(path):
    """
    Normalize a path to use the native OS path separator.
    """
    path = path.replace(posixpath.sep, os.path.sep)
    path = path.replace(ntpath.sep, os.path.sep)
    path = path.rstrip(os.path.sep)
    return path 
开发者ID:spdx,项目名称:tools-python,代码行数:10,代码来源:utils_test.py

示例4: test_nt_helpers

# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import sep [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

示例5: visitFuncDo

# 需要导入模块: import ntpath [as 别名]
# 或者: from ntpath import sep [as 别名]
def visitFuncDo(self, ctx):
        func = self.visit(ctx.specialExpr(0))
        namespace = self.visit(ctx.specialExpr(1)) if ctx.IN() else ''
        args = self.visit(ctx.args(0)) or []
        kwargs = {}

        if ctx.FORM():
            if ctx.NAME():
                kwargs['name'] = str(self.visit(ctx.nameId))
                if ctx.LINKED():
                    kwargs['linked'] = True
            if args:
                kwargs['args'] = args
            if ctx.NOSHOW():
                kwargs['noshow'] = True
            form_call = make_func_code('vfpfunc.do_form', func, **kwargs)
            if ctx.TO():
                return add_args_to_code('{} = {}', (self.visit(ctx.toId), form_call))
            else:
                return form_call

        if os.path.splitext(namespace)[0] == self.filename:
            namespace = ''

        if not namespace:
            if func in self.function_list:
                return make_func_code(func, *args)

            if os.path.splitext(func)[1] in ('.prg', '.mpr', '.spr'):
                namespace = os.path.splitext(func)[0]
                if os.path.splitext(func)[1] in ('.mpr', '.spr'):
                    namespace += os.path.splitext(func)[1].replace('.', '_')
                func = 'MAIN'
            else:
                func = self.scopeId(func, 'func')
                return make_func_code(func, *args)

        if namespace.endswith('.prg'):
            namespace = namespace[:-4]

        if string_type(namespace) and valid_identifier(namespace):
            namespace = ntpath.normpath(ntpath.splitext(namespace)[0]).replace(ntpath.sep, '.')
            if namespace != 'vfpfunc':
                self.imports.append('import ' + namespace)
            mod = CodeStr(namespace)
        else:
            if string_type(namespace):
                namespace = CodeStr(repr(namespace))
            mod = make_func_code('vfpfunc.module', namespace)
        if string_type(func):
            func = CodeStr(func)
            func = add_args_to_code('{}.{}', (mod, func))
            if string_type(namespace):
                return make_func_code(func, *args)
        else:
            func = make_func_code('getattr', mod, func)

        return make_func_code(func, *args) 
开发者ID:mwisslead,项目名称:vfp2py,代码行数:60,代码来源:vfp2py_convert_visitor.py


注:本文中的ntpath.sep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。