From 4d6f0e8f20cf08f559385c19fe0962529a62ef28 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Sat, 16 Mar 2002 02:11:08 +0000 Subject: Add -s/--start and -e/--end switches to manually specify the start and end message numbers (counted from zero) with which to archive. This can be useful when re-archiving a huge .mbox file, even though you have to manually chunk it. --- bin/arch | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/bin/arch b/bin/arch index 5adb9a798..4a603123d 100644 --- a/bin/arch +++ b/bin/arch @@ -1,6 +1,6 @@ #! @PYTHON@ # -# Copyright (C) 1998,1999,2000,2001 by the Free Software Foundation, Inc. +# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -22,7 +22,23 @@ Use this command to rebuild the archives for a mailing list. You may want to do this if you edit some messages in an archive, or remove some messages from an archive. -Usage: %(PROGRAM)s [] [-h] +Usage: %(PROGRAM)s [options] [] [-h] + +Where options are: + -h / --help + Print this help message and exit. + + -s N + --start=N + Start indexing at article N, where article 0 is the first in the mbox. + Defaults to 0. + + -e M + --end=M + End indexing at article M. This script is not very efficient with + respect to memory management, and for large archives, it may not be + possible to index the mbox entirely. For that reason, you can specify + the start and end article numbers. Where is the path to a list's complete mbox archive. Usually this will be some path in the archives/private directory. For example: @@ -60,13 +76,26 @@ def usage(code, msg=''): def main(): # get command line arguments try: - opts, args = getopt.getopt(sys.argv[1:], 'h', ['help']) + opts, args = getopt.getopt(sys.argv[1:], 'hs:e:', + ['help', 'start', 'end']) except getopt.error, msg: usage(1, msg) + start = None + end = None for opt, arg in opts: if opt in ('-h', '--help'): usage(0) + elif opt in ('-s', '--start'): + try: + start = int(arg) + except ValueError: + usage(1) + elif opt in ('-e', '--end'): + try: + end = int(arg) + except ValueError: + usage(1) # grok arguments if len(args) < 1: @@ -115,8 +144,10 @@ def main(): archiver = HyperArchive(mlist) archiver.VERBOSE = 1 - archiver.processUnixMailbox(fp, Article) - archiver.close() + try: + archiver.processUnixMailbox(fp, Article, start, end) + finally: + archiver.close() fp.close() finally: if lock: -- cgit v1.3.1