本文整理汇总了Python中os.path._relpath函数的典型用法代码示例。如果您正苦于以下问题:Python _relpath函数的具体用法?Python _relpath怎么用?Python _relpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_relpath函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _set_rel_paths
def _set_rel_paths(self):
"""Convert all file/directory locations to paths relative to the current working directory.
paml requires that all paths specified in the control file be
relative to the directory from which it is called rather than
absolute paths.
"""
if self.working_dir is not None:
self._rel_working_dir = _relpath(self.working_dir)
if self.alignment is not None:
self._rel_alignment = _relpath(self.alignment, self.working_dir)
if self.out_file is not None:
self._rel_out_file = _relpath(self.out_file, self.working_dir)
开发者ID:vincentdavis,项目名称:biopython,代码行数:13,代码来源:_paml.py
示例2: _make_relative
def _make_relative(file_paths, base=None):
if not base:
base = os.getcwd()
if base[-1] != os.path.sep:
base += os.path.sep
return [_relpath(path, base) if path.startswith(base) else path
for path in file_paths]
开发者ID:dpritsos,项目名称:DoGSWrapper,代码行数:7,代码来源:Dependencies.py
示例3: copy_to_build_dir
def copy_to_build_dir(filepath, root=root):
filepath_abs = os.path.abspath(filepath)
if os.path.isabs(filepath):
filepath = filepath_abs
if filepath_abs.startswith(root):
mod_dir = join_path(build_dir, os.path.dirname(_relpath(filepath, root)))
copy_once_if_newer(filepath_abs, mod_dir)
开发者ID:bjodah,项目名称:cython,代码行数:7,代码来源:Dependencies.py
示例4: execute
def execute(self):
productionLocation = self.productionDetails[2]
fileLocation = self.fileDetails[3]
fileLocation = os.path.join(productionLocation, fileLocation)
fileLocationDir = os.path.dirname(fileLocation)
absRefLoc = os.path.normcase(posixpath.normpath(os.path.join(self.productionDetails[2], self.currentFileLocation)))
absNewLoc = absRefLoc[0:len(absRefLoc)-len(self.currentFilename)]+self.newFilename
newpath = "//"+_relpath(absNewLoc, fileLocationDir)
handle = blendfile.openBlendFile(fileLocation, 'r+b')
for libraryblock in handle.FindBlendFileBlocksWithCode("LI"):
relPath = libraryblock.Get("name").split("\0")[0].replace("\\", "/")
absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
normPath = os.path.normpath(absPath)
if normPath==absRefLoc:
libraryblock.Set("name", newpath)
for imageblock in handle.FindBlendFileBlocksWithCode("IM"):
relPath = imageblock.Get("name").split("\0")[0].replace("\\", "/")
absPath = blendfile.blendPath2AbsolutePath(fileLocation, relPath)
normPath = os.path.normpath(absPath)
if normPath==absRefLoc:
imageblock.Set("name", newpath)
handle.close()
开发者ID:JenevanStudios,项目名称:blender-aid,代码行数:27,代码来源:servicerefactor.py
示例5: replace_url
def replace_url(mo):
""" make sure urls are relative to css path """
css_url = mo.group(0)[4:].strip(")").replace("'", "").replace('"','')
css_path = os.path.join(os.path.dirname(src_fpath),
css_url)
rel_path = _relpath(css_path, fname_dir)
return "url(%s)" % rel_path
开发者ID:steve,项目名称:couchapp,代码行数:8,代码来源:compress_css.py
示例6: copy_to_build_dir
def copy_to_build_dir(filepath, root=root):
filepath = os.path.abspath(filepath)
if os.path.realpath(filepath).startswith(root):
mod_dir = os.path.join(
build_dir, os.path.dirname(_relpath(filepath)))
if not os.path.isdir(mod_dir):
os.makedirs(mod_dir)
shutil.copy(filepath, mod_dir)
开发者ID:gandalf013,项目名称:cython,代码行数:8,代码来源:Dependencies.py
示例7: determineProductionLocation
def determineProductionLocation(productionDir, productionFile, blenderPath):
productionFileDir = os.path.dirname(productionFile)
if blenderPath.startswith("//"):
relpath = os.path.normpath(blenderPath[2:].split("\0")[0]).replace("\\", "/")
abspath = os.path.join(productionFileDir, relpath)
return _relpath(abspath, productionDir)
return blenderPath
开发者ID:jay3sh,项目名称:blender-aid,代码行数:8,代码来源:indexer.py
示例8: copy_to_build_dir
def copy_to_build_dir(filepath, root=os.getcwd()):
filepath_abs = os.path.abspath(filepath)
if os.path.isabs(filepath):
filepath = filepath_abs
if filepath_abs.startswith(root):
# distutil extension depends are relative to cwd
mod_dir = join_path(build_dir,
os.path.dirname(_relpath(filepath, root)))
copy_once_if_newer(filepath_abs, mod_dir)
开发者ID:dpritsos,项目名称:DoGSWrapper,代码行数:9,代码来源:Dependencies.py
示例9: relpath
def relpath(*args):
return _relpath(*args).replace(os.sep, '/')
开发者ID:Riva3000,项目名称:calibre,代码行数:2,代码来源:html_output.py
示例10: callWithLogDir
warnings.warn("Failed to record git status: "+e)
cur = None
def callWithLogDir(fn, root, delete):
root_expanded = os.path.expanduser(root)
if not os.path.isdir(root_expanded) and tunerconfig.config_defaults.output_dir == root:
os.mkdir(root_expanded)
d = tempfile.mkdtemp(prefix='pbtunerun_'+config.name+'_', dir=root_expanded)
if not delete:
print d
global cur
cur = StorageDirsTemplate(d)
try:
return fn()
finally:
if delete:
shutil.rmtree(d)
else:
print d
candidate = lambda cid: cur.candidate(cid)
mutatorlog = lambda m: cur.mutatorlog(m)
inputpfx = lambda size, number: cur.inputpfx(size, number)
clearInputs = lambda : cur.clearInputs()
openCsvStats = lambda name, header: cur.openCsvStats(name, header)
saveFile = lambda path: cur.saveFile(path)
relpath = lambda d: _relpath(d, cur.root)
开发者ID:AikidoGuy,项目名称:petabricks,代码行数:29,代码来源:storagedirs.py
示例11: indexNewFile
def indexNewFile(connection, productionId, productionDir, file, useFileId=None):
"""index a new file"""
if useFileId == None:
newId = connection.execute("select max(id)+1 from file").fetchone()[0]
if newId == None:
newId = 0
connection.execute(
"insert into file values (?,?,?,?,?,?)",
[
newId,
productionId,
os.path.basename(file),
_relpath(file, productionDir),
int(os.path.getmtime(file)),
int(os.path.getsize(file)),
],
)
else:
newId = useFileId
connection.execute(
"update file set lastupdate=?, length=? where id=?",
[int(os.path.getmtime(file)), int(os.path.getsize(file)), newId],
)
if file.endswith(".blend"):
log.info("indexing file " + file)
bf = blendfile.openBlendFile(file)
# index the file
firstElementId = connection.execute("select max(id)+1 from element").fetchone()[0]
offsetElementId = 0
if firstElementId == None:
firstElementId = 0
bfVersion = bf.Header.Version
bfPointerSize = bf.Header.PointerSize
bfLittleEndianness = bf.Header.LittleEndianness
bfCompressed = bf.compressed
bfCurrentScenePointer = None
bfElementId = firstElementId
offsetElementId = offsetElementId + 1
bfCurrentSceneId = None
for block in bf.FindBlendFileBlocksWithCode("GLOB"):
bfCurrentScenePointer = block.Get("curscene")
# flags=block.Get("fileflags")
# bfCompressed = (flags & G_FILE_COMPRESS) == G_FILE_COMPRESS
# print(flags, bfCompressed)
for block in bf.FindBlendFileBlocksWithCode("SC"):
scId = firstElementId + offsetElementId
offsetElementId = offsetElementId + 1
if block.OldAddress == bfCurrentScenePointer:
bfCurrentSceneId = scId
scName = block.Get("id.name")
scWidth = block.Get("r.xsch")
scHeight = block.Get("r.ysch")
scSize = block.Get("r.size")
scXparts = block.Get("r.xparts")
scYparts = block.Get("r.yparts")
scStartFrame = block.Get("r.sfra")
scEndFrame = block.Get("r.efra")
scStep = block.Get("frame_step")
scImageType = formatImageType(block.Get("r.imtype"))
connection.execute(
"insert into element (id, file_id, blendfile_id, name, type, sc_width, sc_height, sc_size, sc_xparts, sc_yparts, sc_startframe, sc_endframe, sc_framestep, sc_outputtype) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
[
scId,
newId,
bfElementId,
scName,
scName[0:2],
scWidth,
scHeight,
scSize,
scXparts,
scYparts,
scStartFrame,
scEndFrame,
scStep,
scImageType,
],
)
for block in bf.FindBlendFileBlocksWithCode("MA"):
scId = firstElementId + offsetElementId
offsetElementId = offsetElementId + 1
scName = block.Get("id.name")
connection.execute(
"insert into element (id, file_id, blendfile_id, name, type) values (?,?,?,?,?)",
[scId, newId, bfElementId, scName, scName[0:2]],
)
for block in bf.FindBlendFileBlocksWithCode("OB"):
# sdna = block.SDNAIndex
dnaIndex = block.SDNAIndex
#.........这里部分代码省略.........
开发者ID:jay3sh,项目名称:blender-aid,代码行数:101,代码来源:indexer.py
示例12: indexOldFile
def indexOldFile(connection, productionId, productionDir, file):
"""remove a file from production scope"""
relpath = _relpath(file, productionDir)
dbFile = connection.execute("select id from file where location=?", [relpath]).fetchone()
connection.execute("delete from element where file_id=?", dbFile)
connection.execute("delete from file where id=?", dbFile)
开发者ID:jay3sh,项目名称:blender-aid,代码行数:6,代码来源:indexer.py
示例13: indexExistingFile
def indexExistingFile(connection, productionId, productionDir, file):
"""index existing file."""
relpath = _relpath(file, productionDir)
dbFile = connection.execute("select id from file where location=?", [relpath]).fetchone()
connection.execute("delete from element where file_id=?", dbFile)
indexNewFile(connection, productionId, productionDir, file, dbFile[0])
开发者ID:jay3sh,项目名称:blender-aid,代码行数:6,代码来源:indexer.py
注:本文中的os.path._relpath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论