2019-12-21 15:58:22 +01:00
|
|
|
import os, logging, argparse
|
|
|
|
|
from glob import glob
|
|
|
|
|
import archive.archive as archive
|
|
|
|
|
import config
|
|
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
|
|
|
|
|
|
def list_archives(archives_dir):
|
|
|
|
|
return [d for d in os.listdir(archives_dir) if os.path.isdir(os.path.join(archives_dir, d))]
|
|
|
|
|
|
|
|
|
|
def run(lists, archives):
|
|
|
|
|
logging.debug("indexing: " + str(lists) + " from " + archives)
|
|
|
|
|
|
2019-12-22 08:21:55 +01:00
|
|
|
for a in lists:
|
|
|
|
|
ar = archive.Archive(a, archives)
|
|
|
|
|
ar.insert_db(config.db)
|
2019-12-21 15:58:22 +01:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
p = argparse.ArgumentParser(description='Mailinglists are dead. Long live mailinglists!')
|
|
|
|
|
p.add_argument('list', metavar="list", help="list(s) to index", nargs="+")
|
|
|
|
|
p.add_argument('--archives', '-a', help="path to archives directory (default='archives')", default=config.archives)
|
|
|
|
|
|
|
|
|
|
args = p.parse_args()
|
|
|
|
|
|
|
|
|
|
if not args.archives:
|
|
|
|
|
args.archives = config.archives
|
|
|
|
|
|
|
|
|
|
if len(args.list) == 1 and args.list[0] == "all":
|
|
|
|
|
args.list = list_archives(args.archives)
|
|
|
|
|
|
|
|
|
|
run(args.list, args.archives)
|
|
|
|
|
|
|
|
|
|
|