def resolve_pathname(self, pathname):
"""Resolve a pathname relative to the competition's base directory.
Accepts None, returning it.
Applies os.expanduser to the pathname.
Doesn't absolutise or normalise the resulting pathname.
Raises ValueError if it can't handle the pathname.
"""
if pathname is None:
return None
if pathname == "":
raise ValueError("empty pathname")
try:
pathname = os.path.expanduser(pathname)
except Exception:
raise ValueError("bad pathname")
try:
return os.path.join(self.base_directory, pathname)
except Exception:
raise ValueError(
"relative path supplied but base directory isn't set")
评论列表
文章目录