def _kp_path(self, path, rel='/'):
if path is None:
return None
path = os.path.relpath(os.path.abspath(os.path.join(rel, path)), rel)
if os.name == 'nt':
path = path.replace(os.path.sep, os.path.altsep)
assert all([not segment.endswith('.kp') for segment in path.split(
'/')[:-1]]), "The post path may not contain a directory named '*.kp'."
if path == '.' or path.startswith('..'):
raise ValueError("Provided path '{}' is outside of the knowledge repository.".format(path))
if not path.endswith('.kp'):
path += '.kp'
return path
评论列表
文章目录