The UnixMailbox does not support reading from stdin as it uses seek()
(at least on Python 2.3). This patch reads the stdin into a StringIO
object.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
import sys, os, re, email
from email.Header import decode_header, make_header
from mailbox import UnixMailbox
import sys, os, re, email
from email.Header import decode_header, make_header
from mailbox import UnixMailbox
+from StringIO import StringIO
from optparse import OptionParser, make_option
from stgit.commands.common import *
from optparse import OptionParser, make_option
from stgit.commands.common import *
if filename:
f = file(filename, 'rb')
else:
if filename:
f = file(filename, 'rb')
else:
+ f = StringIO(sys.stdin.read())
try:
mbox = UnixMailbox(f, email.message_from_file)
try:
mbox = UnixMailbox(f, email.message_from_file)
__create_patch(None, message, author_name, author_email,
author_date, diff, options)
__create_patch(None, message, author_name, author_email,
author_date, diff, options)
- if filename:
- f.close()
def func(parser, options, args):
"""Import a GNU diff file as a new patch
def func(parser, options, args):
"""Import a GNU diff file as a new patch