util: add canon_path()
We need a common definition for canonicalizing paths; the lack of one is causing issues on Windows. Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
3f81eb4195
commit
c20abf8868
|
@ -42,6 +42,17 @@ import textwrap
|
|||
|
||||
import yaml
|
||||
|
||||
def canon_path(path):
|
||||
'''Returns a canonical version of the path.
|
||||
|
||||
This is currently ``os.path.normcase(os.path.abspath(path))``. The
|
||||
path separator is converted to os.sep on platforms where that
|
||||
matters (Windows).
|
||||
|
||||
:param path: path whose canonical name to return; need not
|
||||
refer to an existing file.
|
||||
'''
|
||||
return os.path.normcase(os.path.abspath(path))
|
||||
|
||||
def escapes_directory(path, directory):
|
||||
'''Returns True if `path` escapes parent directory `directory`.
|
||||
|
|
Loading…
Reference in New Issue