Added Blender.sys.relpath(path, start='//')

similar to os.path.relpath but uses blendfile path rather then the current working directory.

Also use python exceptions rather then providing our own ones.
This commit is contained in:
2008-12-03 06:09:07 +00:00
parent 2acd106492
commit aed82a1863
2 changed files with 44 additions and 12 deletions

View File

@@ -174,3 +174,15 @@ def cleanpath (path):
@rtype: string
@return: the cleaned (if necessary) path.
"""
def relpath (path, start="//"):
"""
Returns the path relative to the start,
@note: If the path can be made relative it well start with "//", this is spesific to blender and should be converted to "./" for use as a system path.
@type path: string
@param path: a path name.
@type start: string
@param start: optional argument for the base path, the current blend files base path is used omitted
@rtype: string
@return: The path relative to start
"""