From 7f688a39fbe2022378ae3db9019bb2e74de7621e Mon Sep 17 00:00:00 2001 From: James Troup Date: Sun, 21 Apr 2002 15:39:06 +0000 Subject: [PATCH] remove unused functions, add prefix_multi_line_str --- utils.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/utils.py b/utils.py index 96c61dbf..43da8396 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ # Utility functions # Copyright (C) 2000, 2001 James Troup -# $Id: utils.py,v 1.40 2002-03-14 14:12:04 ajt Exp $ +# $Id: utils.py,v 1.41 2002-04-21 15:39:06 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -57,10 +57,6 @@ def open_file(filename, mode='r'): raise cant_open_exc, filename return f -def touch_file(filename): - fd = os.open(filename, os.O_RDONLY | os.O_CREAT); - os.close(fd); - ###################################################################################### def our_raw_input(prompt=""): @@ -494,11 +490,18 @@ def result_join (original, sep = '\t'): list.append(original[i]); return string.join(list, sep); -def plural (x): - if x > 1: - return "s"; - else: - return ""; +################################################################################ + +def prefix_multi_line_string(str, prefix): + out = ""; + for line in string.split(str, '\n'): + line = string.strip(line); + if line: + out = out + "%s%s\n" % (prefix, line); + # Strip trailing new line + if out: + out = out[:-1]; + return out; ################################################################################ -- GitLab