comments inline
2015-09-14 14:05 GMT+02:00 <olichtne(a)redhat.com>:
From: Ondrej Lichtner <olichtne(a)redhat.com>
Very simple implementation of adding space indentation to multiline
strings. Will be used when pretty printing PerfRepo objects.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/Utils.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index 22d2925..ceb01a3 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -290,3 +290,9 @@ def is_installed(program):
return True
except subprocess.CalledProcessError:
return False
+
+def indent(string, spaces):
+ ret_str = ""
+ for line in string.split("\n"):
+ ret_str += " "*spaces + line + "\n"
is it okay that you add newline on the last line too, where it may not be?
+ return ret_str
maybe changing this to return ret_str.rstrip("\n") would be better
--
2.5.2
_______________________________________________
LNST-developers mailing list
LNST-developers(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
--
Best regards,
Jiri Prochazka
LNST Developer
|
www.lnst-project.org
+420 532 294 633 | jprochaz(a)redhat.com
Red Hat Czech | Purkyňova 71/99, 612 00 Brno