# Copyright 2018 Open Source Foundries Limited. # # SPDX-License-Identifier: Apache-2.0 '''Miscellaneous utilities used by west ''' import shlex import textwrap def quote_sh_list(cmd): '''Transform a command from list into shell string form.''' fmt = ' '.join('{}' for _ in cmd) args = [shlex.quote(s) for s in cmd] return fmt.format(*args) def wrap(text, indent): '''Convenience routine for wrapping text to a consistent indent.''' return textwrap.wrap(text, initial_indent=indent, subsequent_indent=indent)