[PATCH v4 1/2] parsemail: Convert to a management command
Andrew Donnellan
andrew.donnellan at au1.ibm.com
Mon Sep 5 12:16:50 AEST 2016
On 04/09/16 10:12, Stephen Finucane wrote:
> +class Command(base.BaseCommand):
> + help = 'Parse an mbox file and store any patch/comment found.'
> +
> + if django.VERSION < (1, 8):
> + args = '<infile>'
> + option_list = base.BaseCommand.option_list + (
> + make_option(
> + '--list-id',
> + help='mailing list ID. If not supplied, this will be '
> + 'extracted from the mail headers.'),
> + )
> + else:
> + def add_arguments(self, parser):
> + parser.add_argument(
> + 'infile',
> + nargs='?',
> + type=argparse.FileType('r'),
> + default=sys.stdin,
> + help='input mbox file (a filename or stdin)')
> + parser.add_argument(
> + '--list-id',
> + action='store_true',
> + help='mailing list ID. If not supplied, this will be '
> + 'extracted from the mail headers.')
> +
> + def handle(self, *args, **options):
> + path = (args[0] if args else
> + options['infile'] if 'infile' in options else None)
> + stdin = options.get('stdin', sys.stdin)
> +
> + # Attempt to parse the path if provided, and fallback to stdin if not
> + if path and not isinstance(path, file):
This is broken on Python 3 as the 'file' type no longer exists.
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com IBM Australia Limited
More information about the Patchwork
mailing list