def normalize_path(base, filename):
    abs_path = os.path.abspath(base)
    joined = os.path.join(abs_path, filename)
    normalized = os.path.normpath(joined)
    if normalized.startswith(os.path.join(abs_path, '')):
        return normalized
    raise PathTraversalException('Path Traversal detected')
Join and normalize a base path and filename.
dataset/ETHPy150Open psychomario/PyPXE/pypxe/helpers.py/normalize_path