From c20abf8868b0372ce438b97a0bbe68ccc71ca8bf Mon Sep 17 00:00:00 2001 From: Marti Date: Wed, 15 May 2019 11:29:27 -0600 Subject: [PATCH] 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 --- src/west/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/west/util.py b/src/west/util.py index 34b758c..26fbdba 100644 --- a/src/west/util.py +++ b/src/west/util.py @@ -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`.