本文整理匯總了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))