From 9b8b4489558e41b4e5862bf3793cd089e3ad28f8 Mon Sep 17 00:00:00 2001 From: Rickard Bolin Date: Tue, 24 May 2022 07:43:03 +0000 Subject: MLBEDSW-6593: Issue with finding some config files The argument to the lstrip function is a list of all characters that should be stripped from the beginning of the string, in any order. To remove the actual prefix, check if the string starts with the string instead and then remove that amount of characters. The function "removeprefix" was added in python3.9 which does exactly this, but that is not yet available to vela since it supports python 3.7. Signed-off-by: Rickard Bolin Change-Id: Ibc5a173c6d422cb5f55feb80caef6c5c30cf7d39 --- ethosu/vela/vela.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ethosu/vela/vela.py b/ethosu/vela/vela.py index 6207800..ee4de5d 100644 --- a/ethosu/vela/vela.py +++ b/ethosu/vela/vela.py @@ -287,9 +287,10 @@ def generate_supported_ops(): def list_config_files(): - print("\nAvailable config files:\n") + print("Available config files:") + path_length = len(CONFIG_FILES_PATH + os.path.sep) for config in glob.glob(os.path.join(CONFIG_FILES_PATH, "*", "*.ini")): - print(config.lstrip(CONFIG_FILES_PATH + os.path.sep)) + print(config[path_length:]) def main(args=None): @@ -470,11 +471,11 @@ def main(args=None): config_path = os.path.join(CONFIG_FILES_PATH, config) else: print( - f"Warning: Configuration file `{config}` not located in a folder directly under the " - "`config_files` directory. Note that the file depth from the `config_files` directory must be " - "exactly 2 to be discovered via the --list-config-files mechanism " - "(e.g. `config_files/directory_name/my_config_file.ini`). This config file will still be " - "parsed however, and treated as an absolute path config instead." + f"Warning: Configuration file `{config}` is either not located in a folder directly under the " + "`config_files` directory or has not been provided correctly. Note that the file depth from the " + "`config_files` directory must be exactly 2 to be discovered via the --list-config-files " + "mechanism (e.g. `directory_name/my_config_file.ini` located in the config_files directory). " + "This config file will still be parsed however, and treated as an absolute path config instead." ) config_path = config -- cgit v1.2.1