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


Python path.splitdrive方法代码示例

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


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

示例1: _make_tarball

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def _make_tarball(self, target_name):
        # creating something to tar
        tmpdir = self.mkdtemp()
        self.write_file([tmpdir, 'file1'], 'xxx')
        self.write_file([tmpdir, 'file2'], 'xxx')
        os.mkdir(os.path.join(tmpdir, 'sub'))
        self.write_file([tmpdir, 'sub', 'file3'], 'xxx')

        tmpdir2 = self.mkdtemp()
        unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
                            "source and target should be on same drive")

        base_name = os.path.join(tmpdir2, target_name)

        # working with relative paths to avoid tar warnings
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            make_tarball(splitdrive(base_name)[1], '.')
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        tarball = base_name + '.tar.gz'
        self.assertTrue(os.path.exists(tarball))

        # trying an uncompressed one
        base_name = os.path.join(tmpdir2, target_name)
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            make_tarball(splitdrive(base_name)[1], '.', compress=None)
        finally:
            os.chdir(old_dir)
        tarball = base_name + '.tar'
        self.assertTrue(os.path.exists(tarball)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:38,代码来源:test_archive_util.py

示例2: test_make_tarball

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def test_make_tarball(self):
        # creating something to tar
        tmpdir = self.mkdtemp()
        self.write_file([tmpdir, 'file1'], 'xxx')
        self.write_file([tmpdir, 'file2'], 'xxx')
        os.mkdir(os.path.join(tmpdir, 'sub'))
        self.write_file([tmpdir, 'sub', 'file3'], 'xxx')

        tmpdir2 = self.mkdtemp()
        # force shutil to create the directory
        os.rmdir(tmpdir2)
        unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
                            "source and target should be on same drive")

        base_name = os.path.join(tmpdir2, 'archive')

        # working with relative paths to avoid tar warnings
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            _make_tarball(splitdrive(base_name)[1], '.')
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        tarball = base_name + '.tar.gz'
        self.assertTrue(os.path.exists(tarball))

        # trying an uncompressed one
        base_name = os.path.join(tmpdir2, 'archive')
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            _make_tarball(splitdrive(base_name)[1], '.', compress=None)
        finally:
            os.chdir(old_dir)
        tarball = base_name + '.tar'
        self.assertTrue(os.path.exists(tarball)) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:40,代码来源:test_shutil.py

示例3: test_make_tarball

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def test_make_tarball(self):
        # creating something to tar
        tmpdir = self.mkdtemp()
        self.write_file([tmpdir, 'file1'], 'xxx')
        self.write_file([tmpdir, 'file2'], 'xxx')
        os.mkdir(os.path.join(tmpdir, 'sub'))
        self.write_file([tmpdir, 'sub', 'file3'], 'xxx')

        tmpdir2 = self.mkdtemp()
        unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
                            "source and target should be on same drive")

        base_name = os.path.join(tmpdir2, 'archive')

        # working with relative paths to avoid tar warnings
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            make_tarball(splitdrive(base_name)[1], '.')
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        tarball = base_name + '.tar.gz'
        self.assertTrue(os.path.exists(tarball))

        # trying an uncompressed one
        base_name = os.path.join(tmpdir2, 'archive')
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            make_tarball(splitdrive(base_name)[1], '.', compress=None)
        finally:
            os.chdir(old_dir)
        tarball = base_name + '.tar'
        self.assertTrue(os.path.exists(tarball)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:38,代码来源:test_archive_util.py

示例4: _make_tarball

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def _make_tarball(self, tmpdir, target_name, suffix, **kwargs):
        tmpdir2 = self.mkdtemp()
        unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
                            "source and target should be on same drive")

        base_name = os.path.join(tmpdir2, target_name)

        # working with relative paths to avoid tar warnings
        with change_cwd(tmpdir):
            make_tarball(splitdrive(base_name)[1], 'dist', **kwargs)

        # check if the compressed tarball was created
        tarball = base_name + suffix
        self.assertTrue(os.path.exists(tarball))
        self.assertEqual(self._tarinfo(tarball), self._created_files) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:17,代码来源:test_archive_util.py

示例5: splitdrive

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def splitdrive(path=("StringPin", "", {PinSpecifires.INPUT_WIDGET_VARIANT: "PathWidget"}), drive=(REF, ("StringPin", "")), tail=(REF, ("StringPin", ""))):
        '''Split the pathname path into a pair (drive, tail) where drive is either a drive specification or the empty string. On systems which do not use drive specifications, drive will always be the empty string. In all cases, drive + tail will be the same as path.'''
        splited = osPath.splitdrive(path)
        if len(splited):
            drive(splited[0])
            tail(splited[1])
        else:
            drive("")
            tail("")
        return list(splited) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:12,代码来源:PathLib.py

示例6: simplify_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def simplify_path(path):
    """
    Return relative path towards current working directory
    unless it is a separate Windows drive
    """
    cwd = os.getcwd()
    drive_cwd = splitdrive(cwd)[0]
    drive_path = splitdrive(path)[0]
    if drive_path == drive_cwd:
        return relpath(path, cwd)

    return path 
开发者ID:zhajio1988,项目名称:YASA,代码行数:14,代码来源:ostools.py

示例7: rt_MoveRVMAT

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def rt_MoveRVMAT(rvmatName, prefixPath="P:\\"):
    # Construct the output name on the drive. This assumes the rvMat is on the P drive
    outputFolder = path.split(rvmatName)[0]
    
    # Construct the output name in Game terms. This assumes outputFolder is on the P drive
    gameOutputFolder = path.splitdrive(outputFolder)[1]
    gameOutputFolder = gameOutputFolder.strip("\\")

    # Get the textures for this
    textures = rt_readTextures(rvmatName)
    
    outputList = []
    
    for tex in textures:
        texture, replaced = rt_findTextureMatch(tex)
        if replaced is True:
            outputList.append([tex, texture])
        else:
            # Copy the texture
            srcFile = path.join(prefixPath, path.splitext(tex)[0] + ".paa")
            dstFile = path.join(outputFolder, path.basename(texture))
            print("Need to copy " + srcFile + " to " + dstFile)
            try:
                rt_smartCopy(srcFile, dstFile)
            except:
                pass
            
            # Add the replacement to the list
            texBase = path.split(texture)[1]
            outputList.append([tex, path.join(gameOutputFolder,texBase)])
    
    ft_replaceNames(rvmatName, outputList) 
开发者ID:AlwarrenSidh,项目名称:ArmAToolbox,代码行数:34,代码来源:RVMatTools.py

示例8: mt_stripAddonPath

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def mt_stripAddonPath(apath):
    if apath == "" or apath == None: 
        return ""
    if path.isabs(apath):
        p = path.splitdrive(apath)
        return p[1][1:]
    elif apath[0] == '\\':
        return apath[1:]
    else:
        return apath 
开发者ID:AlwarrenSidh,项目名称:ArmAToolbox,代码行数:12,代码来源:RVMatTools.py

示例9: mt_RelocateMaterial

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def mt_RelocateMaterial(textureName, materialName, outputPath, copyRV, prefixPath):
    #print("mt_RelocateMaterial: textureName = ", textureName, " materialName = ", materialName, "\n")
    if len(materialName) > 0:
        baseMat = path.basename(materialName)
        # Construct real path
        if len(path.splitdrive(materialName)[0]) > 0:
            #print("Material has absolute path\n")
            rvmatName = materialName
        else:
            #print("material has relative path\n")
            rvmatName = path.join(prefixPath, materialName)
        
        outputName = path.join(outputPath, baseMat)
        
        if copyRV == True:
            rt_CopyRVMat(rvmatName, outputName, prefixPath)
        else:
            shutil.copy(rvmatName, outputName)
            
        for mat in bpy.data.materials:
            if mat.armaMatProps.rvMat == materialName:
                mat.armaMatProps.rvMat = outputName

    if len(textureName) > 0:
        baseTex = path.basename(textureName)
        if len(path.splitdrive(textureName)[0]) > 0:
            texName = textureName
        else:
            texName = path.join(prefixPath, textureName)

        outputName = path.join(outputPath, baseTex)
        print (texName, outputName)
        # TODO: might need to go through a replacement here...?
        rt_CopyTexture(texName, outputName)
        
        for mat in bpy.data.materials:
            if mat.armaMatProps.texType == 'Texture':
                if mat.armaMatProps.texture == textureName:
                    mat.armaMatProps.texture = outputName 
开发者ID:AlwarrenSidh,项目名称:ArmAToolbox,代码行数:41,代码来源:RVMatTools.py

示例10: test_make_tarball

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import splitdrive [as 别名]
def test_make_tarball(self):
        # creating something to tar
        tmpdir = self.mkdtemp()
        self.write_file([tmpdir, 'file1'], 'xxx')
        self.write_file([tmpdir, 'file2'], 'xxx')
        os.mkdir(os.path.join(tmpdir, 'sub'))
        self.write_file([tmpdir, 'sub', 'file3'], 'xxx')

        tmpdir2 = self.mkdtemp()
        unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
                            "source and target should be on same drive")

        base_name = os.path.join(tmpdir2, 'archive')

        # working with relative paths to avoid tar warnings
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            _make_tarball(splitdrive(base_name)[1], '.')
        finally:
            os.chdir(old_dir)

        # check if the compressed tarball was created
        tarball = base_name + '.tar.gz'
        self.assertTrue(os.path.exists(tarball))

        # trying an uncompressed one
        base_name = os.path.join(tmpdir2, 'archive')
        old_dir = os.getcwd()
        os.chdir(tmpdir)
        try:
            _make_tarball(splitdrive(base_name)[1], '.', compress=None)
        finally:
            os.chdir(old_dir)
        tarball = base_name + '.tar'
        self.assertTrue(os.path.exists(tarball)) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:38,代码来源:test_shutil.py


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