Split arguments following POSIX rather than at all whitespace.
This interface consists of a list of allowed be commands, with one
command per line. Blank lines and lines beginning with '#' are
-ignored, as well anything following a line starting with '--'. All the
-listed commands are executed in order and their output returned.
-Note that currently arguments are split on spaces, so
- "John Doe" -> ['"John', 'Doe"']
-I'm thinking about how to fix this, but for the time being it's best
-to avoid spaces.
+ignored, as well anything following a line starting with '--'. All
+the listed commands are executed in order and their output returned.
+The commands are split into arguments with the POSIX-compliant
+shlex.split().
From jdoe@example.com Fri Apr 18 12:00:00 2008
From: John Doe <jdoe@example.com>
Content-Transfer-Encoding: 8bit
Subject: [be-bug] I'll handle XYZ by release 1.2.3
- assign XYZ John
+ assign XYZ "John Doe <jdoe@example.com>"
status XYZ assigned
severity XYZ critical
target XYZ 1.2.3
import email
from email.mime.multipart import MIMEMultipart
import email.utils
-import libbe.cmdutil, libbe.encoding, libbe.utility
import os
import os.path
import re
-import send_pgp_mime
+import shlex
import sys
import time
import traceback
import doctest
import unittest
+import libbe.cmdutil, libbe.encoding, libbe.utility
+import send_pgp_mime
+
HANDLER_ADDRESS = u"BE Bugs <wking@thor.physics.drexel.edu>"
_THIS_DIR = os.path.abspath(os.path.dirname(__file__))
BE_DIR = _THIS_DIR
continue
if line.startswith(BREAK):
break
- fields = line.split()
+ fields = shlex.split(line)
command,args = (fields[0], fields[1:])
commands.append(Command(self, command, args))
if len(commands) == 0:
-From jdoe@example.com Fri Apr 18 11:18:58 2008
+From jdoe@example.com Fri Apr 18 12:00:00 2008
Message-ID: <abcd@example.com>
Date: Fri, 18 Apr 2008 12:00:00 +0000
From: John Doe <jdoe@example.com>
Content-Transfer-Encoding: 8bit
Subject: [be-bug] Commit message...
-new "test_bug"
-new "test_bug_2"
+new "test bug"
+new "test bug 2"
failing-command
-new "test_bug_3"
+new "test bug 3"
--
This message fails partway through, but the partial changes should be
recorded in a commit...
-
-Note the lack of spaces in the bug summary strings.