blob: a9f8180d1e98b2e373ce1cb7add2ae6503e199a3 [file] [log] [blame]
# 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)