1cc1dc7a3Sopenharmony_ci# SPDX-License-Identifier: Apache-2.0 2cc1dc7a3Sopenharmony_ci# ----------------------------------------------------------------------------- 3cc1dc7a3Sopenharmony_ci# Copyright 2020 Arm Limited 4cc1dc7a3Sopenharmony_ci# 5cc1dc7a3Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6cc1dc7a3Sopenharmony_ci# use this file except in compliance with the License. You may obtain a copy 7cc1dc7a3Sopenharmony_ci# of the License at: 8cc1dc7a3Sopenharmony_ci# 9cc1dc7a3Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 10cc1dc7a3Sopenharmony_ci# 11cc1dc7a3Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 12cc1dc7a3Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13cc1dc7a3Sopenharmony_ci# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14cc1dc7a3Sopenharmony_ci# License for the specific language governing permissions and limitations 15cc1dc7a3Sopenharmony_ci# under the License. 16cc1dc7a3Sopenharmony_ci# ----------------------------------------------------------------------------- 17cc1dc7a3Sopenharmony_ci""" 18cc1dc7a3Sopenharmony_ciA collection of useful utility functions that are not module specific. 19cc1dc7a3Sopenharmony_ci""" 20cc1dc7a3Sopenharmony_ci 21cc1dc7a3Sopenharmony_ciimport os 22cc1dc7a3Sopenharmony_ci 23cc1dc7a3Sopenharmony_ci 24cc1dc7a3Sopenharmony_cidef path_splitall(path): 25cc1dc7a3Sopenharmony_ci """ 26cc1dc7a3Sopenharmony_ci Utility function to split a relative path into its component pieces. 27cc1dc7a3Sopenharmony_ci 28cc1dc7a3Sopenharmony_ci Args: 29cc1dc7a3Sopenharmony_ci path(str): The relative path to split. 30cc1dc7a3Sopenharmony_ci 31cc1dc7a3Sopenharmony_ci Returns: 32cc1dc7a3Sopenharmony_ci list(str): An array of path parts. 33cc1dc7a3Sopenharmony_ci """ 34cc1dc7a3Sopenharmony_ci # Sanity check we have a relative path on Windows 35cc1dc7a3Sopenharmony_ci assert ":" not in path 36cc1dc7a3Sopenharmony_ci 37cc1dc7a3Sopenharmony_ci parts = [] 38cc1dc7a3Sopenharmony_ci while path: 39cc1dc7a3Sopenharmony_ci head, tail = os.path.split(path) 40cc1dc7a3Sopenharmony_ci path = head 41cc1dc7a3Sopenharmony_ci parts.insert(0, tail) 42cc1dc7a3Sopenharmony_ci 43cc1dc7a3Sopenharmony_ci return parts 44