From: Tom Hromatka Date: Thu, 17 Dec 2020 19:43:26 +0000 (-0700) Subject: ftests: Add a utilities file and an indent() function X-Git-Tag: v2.0.3~11^2^2~29^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=647f4ec3e784286ac389e5e56f8fddcc72702b63;p=thirdparty%2Flibcgroup.git ftests: Add a utilities file and an indent() function Add a new file to hold generic utilities for the functional tests. As part of this change, a function that can indent a block of text has been added. Signed-off-by: Tom Hromatka --- diff --git a/ftests/utils.py b/ftests/utils.py new file mode 100644 index 00000000..47a63e5c --- /dev/null +++ b/ftests/utils.py @@ -0,0 +1,25 @@ +# +# Utility functions for the libcgroup functional tests +# +# Copyright (c) 2020 Oracle and/or its affiliates. +# Author: Tom Hromatka +# + +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of version 2.1 of the GNU Lesser General Public License as +# published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +# for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, see . +# + +# function to indent a block of text by cnt number of spaces +def indent(in_str, cnt): + leading_indent = cnt * ' ' + return ''.join(leading_indent + line for line in in_str.splitlines(True))