All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org, "David Kågedal" <davidk@lysator.liu.se>
Subject: [StGit PATCH 3/5] Let parse_patch take a string instead of a file parameter
Date: Fri, 14 Dec 2007 07:25:15 +0100	[thread overview]
Message-ID: <20071214062515.29148.4402.stgit@yoghurt> (raw)
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()

  parent reply	other threads:[~2007-12-14  6:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-14  6:24 [StGit PATCH 0/5] Various odds and ends Karl Hasselström
2007-12-14  6:25 ` [StGit PATCH 1/5] Added --save-template flag to edit command Karl Hasselström
2007-12-14  6:25 ` [StGit PATCH 2/5] Treat filename '-' as stdin/stdout in edit Karl Hasselström
2007-12-14  6:25 ` Karl Hasselström [this message]
2007-12-14  6:25 ` [StGit PATCH 4/5] Make generic --message/--file/--save-template flags Karl Hasselström
2007-12-14  6:44   ` Karl Hasselström
2007-12-14  6:25 ` [StGit PATCH 5/5] Name the exit codes to improve legibility Karl Hasselström
2007-12-14  6:45   ` Karl Hasselström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071214062515.29148.4402.stgit@yoghurt \
    --to=kha@treskal.com \
    --cc=catalin.marinas@gmail.com \
    --cc=davidk@lysator.liu.se \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.