Add API to resolve the abs path with your own basedir
This commit is contained in:
@@ -83,6 +83,21 @@ class FPElem:
|
|||||||
# --------
|
# --------
|
||||||
# filepath
|
# filepath
|
||||||
|
|
||||||
|
def filepath_absolute_resolve(self, basedir=None):
|
||||||
|
"""
|
||||||
|
Resolve the filepath, with the option to override the basedir.
|
||||||
|
"""
|
||||||
|
filepath = self.filepath
|
||||||
|
if filepath.startswith(b'//'):
|
||||||
|
if basedir is None:
|
||||||
|
basedir = self.basedir
|
||||||
|
return os.path.normpath(os.path.join(
|
||||||
|
basedir,
|
||||||
|
utils.compatpath(filepath[2:]),
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
return utils.compatpath(filepath)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def filepath(self):
|
def filepath(self):
|
||||||
return self._get_cb()
|
return self._get_cb()
|
||||||
@@ -93,14 +108,7 @@ class FPElem:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def filepath_absolute(self):
|
def filepath_absolute(self):
|
||||||
filepath = self.filepath
|
return self.filepath_absolute_resolve()
|
||||||
if filepath.startswith(b'//'):
|
|
||||||
return os.path.normpath(os.path.join(
|
|
||||||
self.basedir,
|
|
||||||
utils.compatpath(filepath[2:]),
|
|
||||||
))
|
|
||||||
else:
|
|
||||||
return utils.compatpath(filepath)
|
|
||||||
|
|
||||||
|
|
||||||
class FPElem_block_path(FPElem):
|
class FPElem_block_path(FPElem):
|
||||||
|
Reference in New Issue
Block a user