[StGit PATCH 3/5] Let parse_patch take a string instead of a file parameter
- From
Karl Hasselström <kha@treskal.com>
- Date
- Dec 14, 2007, 06:25 UTC
- Message-ID
- <20071214062515.29148.4402.stgit@yoghurt>
- In-Reply-To
- <20071214062251.29148.86191.stgit@yoghurt>
This makes it more generally useful, since all future callers may not have the input in a file.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
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()