From c37f9747025267b3814a2bb878f6bde0cc8e19d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Karl=20Hasselstr=C3=B6m?= Date: Wed, 12 Dec 2007 22:33:32 +0100 Subject: [PATCH] Let parse_patch take a string instead of a file parameter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This makes it more generally useful, since all future callers may not have the input in a file. Signed-off-by: Karl Hasselström --- stgit/commands/common.py | 6 +++--- stgit/commands/edit.py | 3 ++- stgit/commands/imprt.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/stgit/commands/common.py b/stgit/commands/common.py index 3840387..7cf700e 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -482,11 +482,11 @@ def parse_mail(msg): return (descr, authname, authemail, authdate, diff) -def parse_patch(fobj): - """Parse the input file and return (description, authname, +def parse_patch(text): + """Parse the input text and return (description, authname, authemail, authdate, diff) """ - descr, diff = __split_descr_diff(fobj.read()) + descr, diff = __split_descr_diff(text) descr, authname, authemail, authdate = __parse_description(descr) # we don't yet have an agreed place for the creation date. diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py index 4d1475f..65b54d9 100644 --- a/stgit/commands/edit.py +++ b/stgit/commands/edit.py @@ -100,7 +100,8 @@ def __update_patch(pname, fname, options): f = sys.stdin else: f = open(fname) - message, author_name, author_email, author_date, diff = parse_patch(f) + (message, author_name, author_email, author_date, diff + ) = parse_patch(f.read()) f.close() out.start('Updating patch "%s"' % pname) diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py index 1c21a74..4a4b792 100644 --- a/stgit/commands/imprt.py +++ b/stgit/commands/imprt.py @@ -192,7 +192,7 @@ def __import_file(filename, options, patch = None): parse_mail(msg) else: message, author_name, author_email, author_date, diff = \ - parse_patch(f) + parse_patch(f.read()) if filename: f.close() -- 2.11.0