From: Karl Hasselström Date: Wed, 12 Dec 2007 21:33:32 +0000 (+0100) Subject: Let parse_patch take a string instead of a file parameter X-Git-Tag: v0.15-rc1~363 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/c37f9747025267b3814a2bb878f6bde0cc8e19d2 Let parse_patch take a string instead of a file parameter This makes it more generally useful, since all future callers may not have the input in a file. Signed-off-by: Karl Hasselström --- 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()