From f28dae23c0f22244939877387500c4fb663d8301 Mon Sep 17 00:00:00 2001 From: Patrick Cernko <pcernko@mpi-klsb.mpg.de> Date: Tue, 5 Oct 2021 12:16:44 +0200 Subject: [PATCH] --sympa and --kv (keywords) mode --- mailman-subscribers3.py | 57 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/mailman-subscribers3.py b/mailman-subscribers3.py index 3b36363..f515f3f 100755 --- a/mailman-subscribers3.py +++ b/mailman-subscribers3.py @@ -239,9 +239,9 @@ class MailmanHTMLParser(HTMLParser): def main(): global maxchunk, letters, url_path, page_cset try: - opts, args = getopt.getopt(sys.argv[1:], "ho:rd:fn:cu:Uvs", + opts, args = getopt.getopt(sys.argv[1:], "ho:rd:fn:cKu:Uvs", ["help", "output=", "regular", "digest=", "fullnames", - "nomail=", "csv", "url_path=", "unhide", "verbose", + "nomail=", "sympa", "csv", "kv", "url_path=", "unhide", "verbose", "ssl"]) except: usage(2) @@ -251,7 +251,9 @@ def main(): verbose = False regular = False digest = None + sympa = False csv = False + kv = False unhide = False protocol = 'http' url_path = '/mailman/admin' @@ -270,6 +272,10 @@ def main(): regular = True if o in ("-d", "--digest"): digest = a.lower() + if o in ("-S", "--sympa"): + sympa = True + if o in ("-K", "--kv"): + kv = True if o in ("-c", "--csv"): csv = True if o in ("-u", "--url_path"): @@ -382,6 +388,53 @@ or you may need to specify --url_path. d['_nomail'], d['_ack'], d['_notmetoo'], d['_nodupes'], d['_digest'], d['_plain']), file=fp) continue + if kv: + print('''%s:name=%s +%s:mod=%s +%s:hide=%s +%s:nomail=%s +%s:ack=%s +%s:notmetoo=%s +%s:nodups=%s +%s:digest=%s +%s:plain=%s +''' % ( + email, d['_realname'], + email, d['_mod'], + email, d['_hide'], + email, d['_nomail'], + email, d['_ack'], + email, d['_notmetoo'], + email, d['_nodupes'], + email, d['_digest'], + email, d['_plain']), file=fp) + continue + if sympa: + reception = 'mail' + if d['_nomail'] != "off": + reception = 'nomail' + elif d['_digest'] == 'on': + if d['_plain'] == 'on': + reception = 'digestplain' + else: + reception = 'digest' + elif d['_notmetoo'] == 'on': + reception = 'not_me' + visibility = 'noconceal' + if d['_hide'] == 'on': + visibility = 'conceal' + print(u"""email %s +gecos %s +reception %s +subscribed 1 +visibility %s +""" % ( + email, + d['_realname'], + reception, + visibility +), file=fp) + continue if nomail == 'enabled' and d['_nomail'] != "off": continue if nomail == 'any' and d['_nomail'] == "off": -- GitLab