本文整理汇总了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))
示例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))
示例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))
示例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)
示例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)
示例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
示例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)
示例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
示例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
示例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))