mirror of
https://github.com/aimingmed/aimingmed-ai.git
synced 2026-01-19 13:23:23 +08:00
16 lines
349 B
Python
16 lines
349 B
Python
import os
|
|
|
|
|
|
def sanitize_path(s):
|
|
"""
|
|
Sanitizes the input path by:
|
|
|
|
1. Expanding environment variables
|
|
2. Expanding the home directory ('~')
|
|
3. Calculating the absolute path
|
|
|
|
:param s: input path
|
|
:return: a sanitized version of the input path
|
|
"""
|
|
return os.path.abspath(os.path.expanduser(os.path.expandvars(s)))
|