diff options
| author | Barry Warsaw | 2011-06-15 08:24:14 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2011-06-15 08:24:14 -0400 |
| commit | 8a7ef34b079786ddeba73e8beba11af660d9433e (patch) | |
| tree | 17e967b0f970d2f38cb34a3d71c7c62a45605201 /src/mailman/commands | |
| parent | 65183dcce5e354957c29013ed148f0de24d6884f (diff) | |
| download | mailman-8a7ef34b079786ddeba73e8beba11af660d9433e.tar.gz mailman-8a7ef34b079786ddeba73e8beba11af660d9433e.tar.zst mailman-8a7ef34b079786ddeba73e8beba11af660d9433e.zip | |
Diffstat (limited to 'src/mailman/commands')
| -rw-r--r-- | src/mailman/commands/cli_inject.py | 17 | ||||
| -rw-r--r-- | src/mailman/commands/docs/inject.rst (renamed from src/mailman/commands/docs/inject.txt) | 33 |
2 files changed, 44 insertions, 6 deletions
diff --git a/src/mailman/commands/cli_inject.py b/src/mailman/commands/cli_inject.py index 1d019d9e0..a3e61e2a4 100644 --- a/src/mailman/commands/cli_inject.py +++ b/src/mailman/commands/cli_inject.py @@ -50,7 +50,7 @@ class Inject: self.parser = parser command_parser.add_argument( '-q', '--queue', - type=unicode, help=_("""\ + type=unicode, help=_(""" The name of the queue to inject the message to. QUEUE must be one of the directories inside the qfiles directory. If omitted, the incoming queue is used.""")) @@ -66,9 +66,16 @@ class Inject: # Required positional argument. command_parser.add_argument( 'listname', metavar='LISTNAME', nargs=1, - help=_("""\ + help=_(""" The 'fully qualified list name', i.e. the posting address of the mailing list to inject the message into.""")) + command_parser.add_argument( + '-m', '--metadata', + dest='keywords', action='append', default=[], metavar='KEY=VALUE', + help=_(""" + Additional metadata key/value pairs to add to the message metadata + dictionary. Use the format key=value. Multiple -m options are + allowed.""")) def process(self, args): """See `ICLISubCommand`.""" @@ -104,4 +111,8 @@ class Inject: else: with open(args.filename) as fp: message_text = fp.read() - inject_text(mlist, message_text, switchboard=queue) + keywords = {} + for keyvalue in args.keywords: + key, equals, value = keyvalue.partition('=') + keywords[key] = value + inject_text(mlist, message_text, switchboard=queue, **keywords) diff --git a/src/mailman/commands/docs/inject.txt b/src/mailman/commands/docs/inject.rst index e8c405b07..1c0843ff3 100644 --- a/src/mailman/commands/docs/inject.txt +++ b/src/mailman/commands/docs/inject.rst @@ -14,6 +14,7 @@ line. ... show = False ... filename = None ... listname = None + ... keywords = [] >>> args = FakeArgs() >>> class FakeParser: @@ -130,9 +131,6 @@ But a different queue can be specified on the command line. original_size: 90 version : 3 - # Clean up the tempfile. - >>> os.remove(filename) - Standard input ============== @@ -182,6 +180,30 @@ The message text can also be provided on standard input. >>> args.filename = filename +Metadata +======== + +Additional metadata keys can be provided on the command line. These key/value +pairs get added to the message metadata dictionary when the message is +injected. +:: + + >>> args = FakeArgs() + >>> args.filename = filename + >>> args.listname = ['test@example.com'] + >>> args.keywords = ['foo=one', 'bar=two'] + >>> command.process(args) + + >>> items = get_queue_messages('in') + >>> dump_msgdata(items[0].msgdata) + _parsemsg : False + bar : two + foo : one + listname : test@example.com + original_size: 90 + version : 3 + + Errors ====== @@ -197,3 +219,8 @@ It is also an error to specify a mailing list that doesn't exist. >>> args.listname = ['bogus'] >>> command.process(args) No such list: bogus + + +.. + # Clean up the tempfile. + >>> os.remove(filename) |
