github.com/platonnetwork/platon-go@v0.7.6/cases/common/abspath.py (about) 1 import os 2 3 from conf.settings import BASE_DIR 4 5 6 def abspath(path): 7 """ 8 Based on the project root directory stitching path, 9 The path format is spliced when the relative path is ./path or path/path2. 10 When the path format is absolute path/path, the original path is directly returned. 11 :param path: 12 :return: 13 """ 14 if os.path.isabs(path): 15 return path 16 path = path.lstrip("./") 17 return os.path.abspath(BASE_DIR + "/" + path)