src/Pure/General/mailman.scala
author wenzelm
Wed, 15 Dec 2021 12:41:33 +0100
changeset 74940 fe1d22487427
parent 74938 f76bf7b5baed
child 74941 a63c34c28430
permissions -rw-r--r--
clarified author names;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
72558
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/General/mailman.scala
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     3
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     4
Support for Mailman list servers.
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     5
*/
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     6
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     7
package isabelle
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     8
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
     9
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
    10
import java.net.URL
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
    11
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
    12
import scala.annotation.tailrec
74906
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
    13
import scala.util.matching.Regex
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
    14
import scala.util.matching.Regex.Match
74906
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
    15
72558
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
    16
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
    17
object Mailman
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
    18
{
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
    19
  /* mailing list messages */
72559
274c9986e55b maintain Isabelle mailing list archives;
wenzelm
parents: 72558
diff changeset
    20
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    21
  def is_address(s: String): Boolean =
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    22
    s.contains('@') && s.contains('.') && !s.contains(' ')
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    23
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
    24
  private val standard_name: Map[String, String] =
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    25
    Map(
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    26
      "Aman Pohjola, Johannes (Data61, Kensington NSW)" -> "Johannes Aman Pohjola",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    27
      "Andrei de AraÃjo Formiga" -> "Andrei de Araujo Formiga",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    28
      "Benedikt.AHRENS@unice.fr" -> "Benedikt Ahrens\nBenedikt.AHRENS@unice.fr",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    29
      "Berg, Nils Erik" -> "Nils Erik Berg",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    30
      "Berger U." -> "Ulrich Berger",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    31
      "Bisping, Benjamin" -> "Benjamin Bisping",
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    32
      "Blanchette, J.C." -> "Jasmin Christian Blanchette",
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    33
      "Buday Gergely István" -> "Gergely Buday",
74938
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
    34
      "CALaF1UJ9Uy0vGCu4WkBmbfuPDxG7nFm8hfeCMP+O3g7_5CQ0Bw@mail.gmail.com" -> "",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    35
      "CRACIUN F." -> "Florin Craciun",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    36
      "Carsten Schuermann" -> "Carsten Schürmann",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    37
      "Chris" -> "",
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    38
      "Christoph Lueth" -> "Christoph Lüth",
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    39
      "Claude Marche" -> "Claude Marché",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    40
      "Daniel StÃwe" -> "Daniel Stüwe",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    41
      "Daniel.Matichuk@data61.csiro.au" -> "Daniel Matichuk\nDaniel.Matichuk@data61.csiro.au",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    42
      "Daniel.Matichuk@nicta.com.au" -> "Daniel Matichuk\nDaniel.Matichuk@nicta.com.au",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    43
      "David MENTRE" -> "David MENTRÉ",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    44
      "Dey, Katie" -> "Katie Dey",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    45
      "Dr. Brendan Patrick Mahony" -> "Brendan Mahony",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    46
      "Farn" -> "Farn Wang",
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    47
      "Farquhar, Colin I" -> "Colin Farquhar",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    48
      "Fernandez, Matthew" -> "Matthew Fernandez",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    49
      "Filip Maric" -> "Filip Marić",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    50
      "Filip MariÄ" -> "Filip Marić",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    51
      "Fleury Mathias" -> "Mathias Fleury",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    52
      "Francisco Jose CHAVES ALONSO" -> "Francisco Jose Chaves Alonso",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    53
      "Frederic Tuong (Dr)" -> "Frederic Tuong",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    54
      "Fulya" -> "Fulya Horozal",
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    55
      "George K." -> "George Karabotsos",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    56
      "Gidon Ernst" -> "Gidon ERNST",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    57
      "Gransden, Thomas" -> "Thomas Gransden",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    58
      "Hans-JÃrg Schurr" -> "Hans-Jörg Schurr",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    59
      "Henri DEBRAT" -> "Henri Debrat",
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
    60
      "Hitoshi Ohsaki (RTA publicity chair)" -> "Hitoshi Ohsaki",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    61
      "Häuselmann Rafael" -> "Rafael Häuselmann",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    62
      "Isabelle" -> "",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    63
      "J. Juhas (TUM)" -> "Jonatan Juhas",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    64
      "Jackson, Vincent (Data61, Kensington NSW)" -> "Vincent Jackson",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    65
      "Janney, Mark-P26816" -> "Mark Janney",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    66
      "Jean François Molderez" -> "Jean-François Molderez",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    67
      "Jean-Francois Molderez" -> "Jean-François Molderez",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    68
      "John R Harrison" -> "John Harrison",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    69
      "Jose DivasÃn" -> "Jose Divasón",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    70
      "Julian" -> "",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    71
      "Julien" -> "",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    72
      "Klein, Gerwin (Data61, Kensington NSW)" -> "Gerwin Klein",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    73
      "Kobayashi, Hidetsune" -> "Hidetsune Kobayashi",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    74
      "Kylie Williams (IND)" -> "Kylie Williams",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    75
      "Laarman, A.W." -> "A.W. Laarman",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    76
      "Laurent Thery" -> "Laurent Théry",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    77
      "Li, Chanjuan" -> "Li Chanjuan",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    78
      "Lochbihler Andreas" -> "Andreas Lochbihler",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    79
      "Luckhardt, Daniel" -> "Daniel Luckhardt",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    80
      "Lutz Schroeder" -> "Lutz Schröder",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    81
      "Lutz SchrÃder" -> "Lutz Schröder",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    82
      "MACKENZIE Carlin" -> "Carlin MACKENZIE",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    83
      "Makarius" -> "Makarius Wenzel",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    84
      "Marco" -> "",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    85
      "Mark" -> "",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    86
      "Markus Mueller-Olm" -> "Markus Müller-Olm",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    87
      "Markus" -> "",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    88
      "Marmsoler, Diego" -> "Diego Marmsoler",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    89
      "Martin Klebermass" -> "Martin Klebermaß",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    90
      "Matthew" -> "",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    91
      "Matthews, John R" -> "John Matthews",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    92
      "McCarthy, Jim (C3ID)" -> "Jim McCarthy",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    93
      "McCue, Brian" -> "Brian McCue",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
    94
      "Michael FÃrber" -> "Michael Färber",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    95
      "Michel" -> "",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    96
      "Miranda, Brando" -> "Brando Miranda",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    97
      "Moscato, Mariano M. \\(LARC-D320\\)\\[NATIONAL INSTITUTE OF AEROSPACE\\]" -> "Mariano M. Moscato",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    98
      "Mr Julian Fell" -> "Julian Fell",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
    99
      "Mueller Peter" -> "Peter Müller",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   100
      "Munoz, Cesar Augusto (LARC-D320)" -> "Cesar A. Munoz",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   101
      "Nadel, Alexander" -> "Alexander Nadel",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   102
      "Nagashima, Yutaka" -> "Yutaka Nagashima",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   103
      "Norrish, Michael (Data61, Acton)" -> "Michael Norrish",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   104
      "O'Leary, John W" -> "John W O'Leary",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   105
      "Omar Montano Rivas" -> "Omar Montaño Rivas",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   106
      "Omar MontaÃo Rivas" -> "Omar Montaño Rivas",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   107
      "OndÅej KunÄar" -> "Ondřej Kunčar",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   108
      "PAQUI LUCIO" -> "Paqui Lucio",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   109
      "Pal, Abhik" -> "Abhik Pal",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   110
      "Pasupuleti, Vijay" -> "Vijay Pasupuleti",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   111
      "Peter Vincent Homeier" -> "Peter V. Homeier",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   112
      "Peter" -> "",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   113
      "Philipp Ruemmer" -> "Philipp Rümmer",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   114
      "Philipp RÃmmer" -> "Philipp Rümmer",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   115
      "RTA publicity chair" -> "",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   116
      "Raamsdonk, F. van" -> "Femke van Raamsdonk",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   117
      "Raul Gutierrez" -> "Raúl Gutiérrez",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   118
      "Renà Thiemann" -> "René Thiemann",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   119
      "Ridgway, John V. E." -> "John V. E. Ridgway",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   120
      "Roggenbach M." -> "Markus Roggenbach",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   121
      "Rosu, Grigore" -> "Grigore Rosu",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   122
      "Rozman, Mihaela" -> "Mihaela Rozman",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   123
      "Schmaltz, J." -> "Julien Schmaltz",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   124
      "Serguei A. Mokhov on behalf of PST-11" -> "Serguei A. Mokhov",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   125
      "Serguei Mokhov" -> "Serguei A. Mokhov",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   126
      "Shumeiko, Igor" -> "Igor Shumeiko",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   127
      "Siek, Jeremy" -> "Jeremy Siek",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   128
      "Silvio.Ranise@loria.fr" -> "Silvio Ranise\nSilvio.Ranise@loria.fr",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   129
      "Siu, Tony" -> "Tony Siu",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   130
      "Stüber, Sebastian" -> "Sebastian Stüber",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   131
      "Thiemann, Rene" -> "René Thiemann",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   132
      "Thiemann, René" -> "René Thiemann",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   133
      "Thomas Arthur Leck Sewell" -> "Thomas Sewell",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   134
      "Thomas Goethel" -> "Thomas Göthel",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   135
      "Thomas.Sewell@data61.csiro.au" -> "Thomas Sewell\nThomas.Sewell@data61.csiro.au",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   136
      "Toby.Murray@data61.csiro.au" -> "Toby Murray\nToby.Murray@data61.csiro.au",
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   137
      "Urban, Christian" -> "Christian Urban",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   138
      "Ursula Eschbach" -> "",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   139
      "Van Staden Stephan" -> "Stephan van Staden",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   140
      "Viktor Kuncak" -> "Viktor Kunčak",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   141
      "Viorel Preoteasaa" -> "Viorel Preoteasa",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   142
      "Wickerson, John P" -> "John Wickerson",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   143
      "Wong, Yat" -> "Yat Wong",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   144
      "YAMADA, Akihisa" -> "Akihisa Yamada",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   145
      "YliÃs Falcone" -> "Yliès Falcone",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   146
      "amir mohajeri" -> "Amir Mohajeri",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   147
      "aniello murano" -> "Aniello Murano",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   148
      "barzan stefania" -> "Stefania Barzan",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   149
      "benhamou" -> "Belaid Benhamou",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   150
      "charmi panchal" -> "Charmi Panchal",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   151
      "chen kun" -> "Chen Kun",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   152
      "chunhan wu" -> "Chunhan Wu",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   153
      "daniel de la concepción sáez" -> "Daniel de la Concepción Sáez",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   154
      "daniel.luckhardt@mathematik.uni-goettingen.de" -> "Logiker@gmx.net",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   155
      "david streader" -> "David Streader",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   156
      "eschbach@in.tum.de" -> "",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   157
      "f.rabe@jacobs-university.de" -> "florian.rabe@fau.de",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   158
      "florian@haftmann-online.de" -> "haftmann@in.tum.de",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   159
      "fredegar@haftmann-online.de" -> "haftmann@in.tum.de",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   160
      "gallais @ ensl.org" -> "Guillaume Allais",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   161
      "geng chen" -> "Geng Chen",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   162
      "henning.seidler" -> "Henning Seidler",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   163
      "hkb" -> "Hidetsune Kobayashi",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   164
      "julien@RadboudUniversity" -> "",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   165
      "jun sun" -> "Jun Sun",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   166
      "jwang whu.edu.cn (jwang)" -> "jwang",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   167
      "kostas pouliasis" -> "Kostas Pouliasis",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   168
      "kristof.teichel@ptb.de" -> "Kristof Teichel\nkristof.teichel@ptb.de",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   169
      "lucas cavalcante" -> "Lucas Cavalcante",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   170
      "mahmoud abdelazim" -> "Mahmoud Abdelazim",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   171
      "manish surolia" -> "Manish Surolia",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   172
      "mantel" -> "Heiko Mantel",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   173
      "marco caminati" -> "Marco Caminati",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   174
      "merz@loria.fr" -> "stephan.merz@loria.fr",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   175
      "michel levy" -> "Michel Levy",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   176
      "michel.levy2009@laposte.net" -> "Michel Levy\nmichel.levy2009@laposte.net",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   177
      "nemouchi" -> "Yakoub Nemouchi",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   178
      "patrick barlatier" -> "Patrick Barlatier",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   179
      "patrick dabou" -> "Patrick Dabou",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   180
      "paul zimmermann" -> "Paul Zimmermann",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   181
      "popescu2@illinois.edu" -> "Andrei Popescu",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   182
      "recruiting" -> "",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   183
      "roux cody" -> "Cody Roux",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   184
      "scott constable" -> "Scott Constable",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   185
      "superuser@mattweidner.com" -> "Matthew Weidner\nsuperuser@mattweidner.com",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   186
      "urban@math.lmu.de" -> "Christian Urban\nurban@math.lmu.de",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   187
      "veronique.cortier@loria.fr" -> "Veronique.Cortier@loria.fr",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   188
      "vikram singh" -> "Vikram Singh",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   189
      "wenzelm@in.tum.de" -> "makarius@sketis.net",
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   190
      "werner@lix.polytechnique.fr" -> "Benjamin Werner\nwerner@lix.polytechnique.fr",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   191
      "wmansky@cs.princeton.edu" -> "William Mansky\nwmansky@cs.princeton.edu",
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   192
      "y.nemouchi@ensbiotech.edu.dz" -> "Yakoub Nemouchi\ny.nemouchi@ensbiotech.edu.dz",
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   193
      "ÐÑÐÐÐÑÐÐÐ ÐÐÐÐÐÐÐÑÐÐÐÑ ÐÐÐÑÐÐÐ" -> "",
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   194
      "∀X.Xπ - Tutorials about Proofs" -> "Bruno Woltzenlogel Paleo",
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   195
    ).withDefault(identity)
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   196
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   197
  def standard_author_info(author_info: List[String]): List[String] =
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   198
    author_info.flatMap(s => split_lines(standard_name.getOrElse(s, s))).distinct
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   199
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   200
  sealed case class Message(
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   201
    name: String,
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   202
    date: Date,
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   203
    title: String,
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   204
    author_info: List[String],
74934
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   205
    body: String,
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   206
    tags: List[String])
72558
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
   207
  {
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   208
    if (author_info.isEmpty || author_info.exists(_.isEmpty)) {
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   209
      error("Bad author information in " + quote(name))
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   210
    }
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   211
74925
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   212
    override def toString: String = name
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   213
   }
74906
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   214
74933
0f27dcd030b8 clarified signature;
wenzelm
parents: 74932
diff changeset
   215
  object Messages
74925
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   216
  {
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   217
    type Graph = isabelle.Graph[String, Message]
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   218
74933
0f27dcd030b8 clarified signature;
wenzelm
parents: 74932
diff changeset
   219
    def apply(msgs: List[Message]): Messages =
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   220
    {
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   221
      def make_node(g: Graph, node: String, msg: Message): Graph =
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   222
        if (g.defined(node) && Date.Ordering.compare(g.get_node(node).date, msg.date) >= 0) g
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   223
        else g.default_node(node, msg)
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   224
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   225
      def connect_nodes(g: Graph, nodes: List[String]): Graph =
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   226
        nodes match {
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   227
          case Nil => g
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   228
          case a :: bs => bs.foldLeft(g)({ case (g1, b) => g1.add_edge(a, b).add_edge(b, a) })
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   229
        }
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   230
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   231
      new Messages(msgs.sortBy(_.date)(Date.Ordering),
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   232
        msgs.foldLeft[Graph](Graph.string)(
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   233
          { case (graph, msg) =>
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   234
              val nodes = msg.author_info
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   235
              connect_nodes(nodes.foldLeft(graph)(make_node(_, _, msg)), nodes)
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   236
          }))
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   237
    }
74934
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   238
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   239
    def find(dir: Path): Messages =
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   240
    {
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   241
      val msgs =
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   242
        for {
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   243
          archive <- List(Isabelle_Users, Isabelle_Dev)
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   244
          msg <- archive.find_messages(dir + Path.basic(archive.list_name))
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   245
        } yield msg
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   246
      Messages(msgs)
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   247
    }
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   248
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   249
    sealed case class Cluster(author_info: List[String])
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   250
    {
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   251
      val (addresses, names) = author_info.partition(is_address)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   252
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   253
      val name: String =
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   254
        names.headOption getOrElse {
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   255
          addresses match {
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   256
            case a :: _ => a.substring(0, a.indexOf('@')).replace('.', ' ')
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   257
            case Nil => error("Empty cluster")
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   258
          }
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   259
        }
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   260
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   261
      val name_lowercase: String = Word.lowercase(name)
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   262
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   263
      def get_address: Option[String] = addresses.headOption
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   264
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   265
      def unique: Boolean = names.length == 1 && addresses.length == 1
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   266
      def multi: Boolean = names.length > 1 || addresses.length > 1
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   267
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   268
      def print: String =
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   269
      {
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   270
        val entries = names ::: (if (addresses.isEmpty) Nil else List("")) ::: addresses
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   271
        entries.mkString("\n  * ", "\n    ", "")
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   272
      }
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   273
    }
74933
0f27dcd030b8 clarified signature;
wenzelm
parents: 74932
diff changeset
   274
  }
0f27dcd030b8 clarified signature;
wenzelm
parents: 74932
diff changeset
   275
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   276
  class Messages private(val sorted: List[Message], val graph: Messages.Graph)
74933
0f27dcd030b8 clarified signature;
wenzelm
parents: 74932
diff changeset
   277
  {
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   278
    override def toString: String = "Messages(" + sorted.size + ")"
74925
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   279
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   280
    object Node_Ordering extends scala.math.Ordering[String]
74933
0f27dcd030b8 clarified signature;
wenzelm
parents: 74932
diff changeset
   281
    {
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   282
      override def compare(a: String, b: String): Int =
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   283
        Date.Rev_Ordering.compare(graph.get_node(a).date, graph.get_node(b).date)
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   284
    }
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   285
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   286
    def get_cluster(msg: Message): Messages.Cluster =
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   287
      Messages.Cluster(graph.all_succs(msg.author_info).sorted.sorted(Node_Ordering))
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   288
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   289
    def get_name(msg: Message): String = get_cluster(msg).name
74925
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   290
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   291
    def get_address(msg: Message): String =
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   292
      get_cluster(msg).get_address getOrElse error("No author address for " + quote(msg.name))
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   293
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   294
    def check(check_all: Boolean, check_multi: Boolean = false): Unit =
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   295
    {
74940
fe1d22487427 clarified author names;
wenzelm
parents: 74938
diff changeset
   296
      val clusters = sorted.map(get_cluster).distinct.sortBy(_.name_lowercase)
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   297
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   298
      if (check_all) {
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   299
        Output.writeln(cat_lines("clusters:" :: clusters.map(_.print)))
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   300
      }
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   301
      else {
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   302
        val multi = if (check_multi) clusters.filter(_.multi) else Nil
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   303
        if (multi.nonEmpty) {
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   304
          Output.writeln(cat_lines("ambiguous clusters:" :: multi.map(_.print)))
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   305
        }
74925
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   306
      }
74933
0f27dcd030b8 clarified signature;
wenzelm
parents: 74932
diff changeset
   307
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   308
      val unknown = clusters.filter(cluster => cluster.get_address.isEmpty)
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   309
      if (unknown.nonEmpty) {
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   310
        Output.writeln(cat_lines("\nunknown mail:" :: unknown.map(_.print)))
74933
0f27dcd030b8 clarified signature;
wenzelm
parents: 74932
diff changeset
   311
      }
74925
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   312
    }
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   313
  }
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   314
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   315
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   316
  /* mailing list archives */
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   317
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   318
  abstract class Archive(
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   319
    url: URL,
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   320
    name: String = "",
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   321
    tag: String = "")
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   322
  {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   323
    def message_regex: Regex
74923
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   324
    def message_content(name: String, lines: List[String]): Message
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   325
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   326
    def message_match(lines: List[String], re: Regex): Option[Match] =
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   327
      lines.flatMap(re.findFirstMatchIn(_)).headOption
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   328
74931
1753dade9a24 more data integrity: name vs. address;
wenzelm
parents: 74930
diff changeset
   329
    def make_name(str: String): String =
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   330
    {
74937
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   331
      val s =
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   332
        str.trim.replaceAll("""\s+""", " ").replaceAll(" at ", "@")
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   333
          .replace("mailbroy.informatik.tu-muenchen.de", "in.tum.de")
450597bdd2d3 more standard author_info;
wenzelm
parents: 74936
diff changeset
   334
          .replace("informatik.tu-muenchen.de", "in.tum.de")
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   335
      if (s.startsWith("=") && s.endsWith("=")) "" else s
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   336
    }
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   337
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   338
    def make_body(lines: List[String]): String =
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   339
      cat_lines(Library.take_suffix[String](_.isEmpty, lines)._1)
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   340
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   341
    private val main_url: URL =
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   342
      Url(Library.take_suffix[Char](_ == '/', Url.trim_index(url).toString.toList)._1.mkString + "/")
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   343
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   344
    private val main_html = Url.read(main_url)
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   345
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   346
    val list_name: String =
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   347
    {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   348
      val title =
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   349
        """<title>The ([^</>]*) Archives</title>""".r.findFirstMatchIn(main_html).map(_.group(1))
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   350
      (proper_string(name) orElse title).getOrElse(error("Failed to determine mailing list name"))
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   351
    }
72558
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
   352
    override def toString: String = list_name
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
   353
74923
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   354
    def full_name(href: String): String = list_name + "/" + href
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   355
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   356
    def list_tag: String = proper_string(tag).getOrElse(list_name)
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   357
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   358
    def read_text(href: String): String = Url.read(new URL(main_url, href))
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   359
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   360
    def hrefs_text: List[String] =
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   361
      """href="([^"]+\.txt(?:\.gz)?)"""".r.findAllMatchIn(main_html).map(_.group(1)).toList
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   362
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   363
    def hrefs_msg: List[String] =
74906
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   364
      (for {
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   365
        href <- """href="([^"]+)/date.html"""".r.findAllMatchIn(main_html).map(_.group(1))
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   366
        html = read_text(href + "/date.html")
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   367
        msg <- message_regex.findAllMatchIn(html).map(_.group(1))
74906
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   368
      } yield href + "/" + msg).toList
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   369
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   370
    def get(target_dir: Path, href: String, progress: Progress = new Progress): Option[Path] =
72558
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
   371
    {
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
   372
      val dir = target_dir + Path.basic(list_name)
74906
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   373
      val path = dir + Path.explode(href)
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   374
      val url = new URL(main_url, href)
74906
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   375
      val connection = url.openConnection
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   376
      try {
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   377
        val length = connection.getContentLengthLong
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   378
        val timestamp = connection.getLastModified
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   379
        val file = path.file
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   380
        if (file.isFile && file.length == length && file.lastModified == timestamp) None
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   381
        else {
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   382
          Isabelle_System.make_directory(path.dir)
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   383
          progress.echo("Getting " + url)
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   384
          val bytes =
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   385
            using(connection.getInputStream)(Bytes.read_stream(_, hint = length.toInt max 1024))
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   386
          Bytes.write(file, bytes)
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   387
          file.setLastModified(timestamp)
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   388
          Some(path)
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   389
        }
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   390
      }
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   391
      finally { connection.getInputStream.close() }
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   392
    }
72558
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
   393
74906
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   394
    def download_text(target_dir: Path, progress: Progress = new Progress): List[Path] =
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   395
      hrefs_text.flatMap(get(target_dir, _, progress = progress))
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   396
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   397
    def download_msg(target_dir: Path, progress: Progress = new Progress): List[Path] =
9702913db56c more Mailman content;
wenzelm
parents: 74905
diff changeset
   398
      hrefs_msg.flatMap(get(target_dir, _, progress = progress))
74907
af2323593473 more Mailman archives;
wenzelm
parents: 74906
diff changeset
   399
af2323593473 more Mailman archives;
wenzelm
parents: 74906
diff changeset
   400
    def download(target_dir: Path, progress: Progress = new Progress): List[Path] =
af2323593473 more Mailman archives;
wenzelm
parents: 74906
diff changeset
   401
      download_text(target_dir, progress = progress) :::
af2323593473 more Mailman archives;
wenzelm
parents: 74906
diff changeset
   402
      download_msg(target_dir, progress = progress)
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   403
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   404
    def make_title(str: String): String =
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   405
    {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   406
      val Trim1 = ("""\s*\Q[""" + list_tag + """]\E\s*(.*)""").r
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   407
      val Trim2 = """(?i:(?:re|fw|fwd)\s*:\s*)(.*)""".r
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   408
      val Trim3 = """\[\s*(.*?)\s*\]""".r
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   409
      @tailrec def trim(s: String): String =
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   410
        s match {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   411
          case Trim1(s1) => trim(s1)
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   412
          case Trim2(s1) => trim(s1)
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   413
          case Trim3(s1) => trim(s1)
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   414
          case _ => s
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   415
        }
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   416
      trim(str)
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   417
    }
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   418
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   419
    def get_messages(): List[Message] =
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   420
      for (href <- hrefs_msg) yield message_content(href, split_lines(read_text(href)))
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   421
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   422
    def find_messages(dir: Path): List[Message] =
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   423
    {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   424
      for {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   425
        file <- File.find_files(dir.file, file => file.getName.endsWith(".html"))
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   426
        rel_path <- File.relative_path(dir, File.path(file))
74923
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   427
      }
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   428
      yield {
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   429
        val name = full_name(rel_path.implode)
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   430
        message_content(name, split_lines(File.read(file)))
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   431
      }
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   432
    }
72558
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
   433
  }
72559
274c9986e55b maintain Isabelle mailing list archives;
wenzelm
parents: 72558
diff changeset
   434
74932
wenzelm
parents: 74931
diff changeset
   435
  private class Message_Chunk(bg: String = "", en: String = "")
wenzelm
parents: 74931
diff changeset
   436
  {
wenzelm
parents: 74931
diff changeset
   437
    def unapply(lines: List[String]): Option[List[String]] =
wenzelm
parents: 74931
diff changeset
   438
    {
wenzelm
parents: 74931
diff changeset
   439
      val res1 =
wenzelm
parents: 74931
diff changeset
   440
        if (bg.isEmpty) Some(lines)
wenzelm
parents: 74931
diff changeset
   441
        else {
wenzelm
parents: 74931
diff changeset
   442
          lines.dropWhile(_ != bg) match {
wenzelm
parents: 74931
diff changeset
   443
            case Nil => None
wenzelm
parents: 74931
diff changeset
   444
            case _ :: rest => Some(rest)
wenzelm
parents: 74931
diff changeset
   445
          }
wenzelm
parents: 74931
diff changeset
   446
        }
wenzelm
parents: 74931
diff changeset
   447
      if (en.isEmpty) res1
wenzelm
parents: 74931
diff changeset
   448
      else {
wenzelm
parents: 74931
diff changeset
   449
        res1 match {
wenzelm
parents: 74931
diff changeset
   450
          case None => None
wenzelm
parents: 74931
diff changeset
   451
          case Some(lines1) =>
wenzelm
parents: 74931
diff changeset
   452
            val lines2 = lines1.takeWhile(_ != en)
wenzelm
parents: 74931
diff changeset
   453
            if (lines1.drop(lines2.length).isEmpty) None else Some(lines2)
wenzelm
parents: 74931
diff changeset
   454
        }
wenzelm
parents: 74931
diff changeset
   455
      }
wenzelm
parents: 74931
diff changeset
   456
    }
wenzelm
parents: 74931
diff changeset
   457
wenzelm
parents: 74931
diff changeset
   458
    def get(lines: List[String]): List[String] =
wenzelm
parents: 74931
diff changeset
   459
      unapply(lines) getOrElse
wenzelm
parents: 74931
diff changeset
   460
        error("Missing delimiters:" +
wenzelm
parents: 74931
diff changeset
   461
          (if (bg.nonEmpty) " " else "") + bg +
wenzelm
parents: 74931
diff changeset
   462
          (if (en.nonEmpty) " " else "") + en)
wenzelm
parents: 74931
diff changeset
   463
  }
wenzelm
parents: 74931
diff changeset
   464
72559
274c9986e55b maintain Isabelle mailing list archives;
wenzelm
parents: 72558
diff changeset
   465
74930
e9506503efea tuned comments;
wenzelm
parents: 74925
diff changeset
   466
  /* isabelle-users mailing list */
72559
274c9986e55b maintain Isabelle mailing list archives;
wenzelm
parents: 72558
diff changeset
   467
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   468
  object Isabelle_Users extends Archive(
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   469
    Url("https://lists.cam.ac.uk/pipermail/cl-isabelle-users"),
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   470
    name = "isabelle-users", tag = "isabelle")
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   471
  {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   472
    override def message_regex: Regex = """<li><a name="\d+" href="(msg\d+\.html)">""".r
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   473
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   474
    private object Head extends
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   475
      Message_Chunk(bg = "<!--X-Head-of-Message-->", en = "<!--X-Head-of-Message-End-->")
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   476
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   477
    private object Body extends
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   478
      Message_Chunk(bg = "<!--X-Body-of-Message-->", en = "<!--X-Body-of-Message-End-->")
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   479
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   480
    private object Date_Format
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   481
    {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   482
      private val Trim1 = """\w+,\s*(.*)""".r
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   483
      private val Trim2 = """(.*?)\s*\(.*\)""".r
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   484
      private val Format =
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   485
        Date.Format(
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   486
          "d MMM uuuu H:m:s Z",
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   487
          "d MMM uuuu H:m:s z",
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   488
          "d MMM yy H:m:s Z",
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   489
          "d MMM yy H:m:s z")
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   490
      def unapply(s: String): Option[Date] =
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   491
      {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   492
        val s0 = s.replaceAll("""\s+""", " ")
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   493
        val s1 =
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   494
          s0 match {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   495
            case Trim1(s1) => s1
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   496
            case _ => s0
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   497
          }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   498
        val s2 =
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   499
          s1 match {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   500
            case Trim2(s2) => s2
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   501
            case _ => s1
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   502
          }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   503
        Format.unapply(s2)
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   504
      }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   505
    }
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   506
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   507
    override def make_name(str: String): String =
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   508
    {
74935
dc62948c6080 more data integrity: name vs. address;
wenzelm
parents: 74934
diff changeset
   509
      val s = Library.perhaps_unsuffix(" via Cl-isabelle-users", super.make_name(str))
74925
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   510
      if (s == "cl-isabelle-users@lists.cam.ac.uk") "" else s
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   511
    }
4bc306cb2832 more data integrity: name vs. address;
wenzelm
parents: 74924
diff changeset
   512
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   513
    object Address
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   514
    {
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   515
      private def anchor(s: String): String = """<a href="[^"]*">""" + s + """</a>"""
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   516
      private def angl(s: String): String = """&lt;""" + s + """&gt;"""
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   517
      private def quot(s: String): String = """&quot;""" + s + """&quot;"""
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   518
      private def paren(s: String): String = """\(""" + s + """\)"""
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   519
      private val adr = """([^<>]*? at [^<>]*?)"""
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   520
      private val any = """([^<>]*?)"""
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   521
      private val spc = """\s*"""
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   522
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   523
      private val Name1 = quot(anchor(any)).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   524
      private val Name2 = quot(any).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   525
      private val Name_Adr1 = (quot(anchor(any)) + spc + angl(anchor(adr))).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   526
      private val Name_Adr2 = (quot(any) + spc + angl(anchor(adr))).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   527
      private val Name_Adr3 = (anchor(any) + spc + angl(anchor(adr))).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   528
      private val Name_Adr4 = (any + spc + angl(anchor(adr))).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   529
      private val Adr_Name1 = (angl(anchor(adr)) + spc + paren(any)).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   530
      private val Adr_Name2 = (anchor(adr) + spc + paren(any)).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   531
      private val Adr1 = angl(anchor(adr)).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   532
      private val Adr2 = anchor(adr).r
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   533
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   534
      def parse(s: String): List[String] =
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   535
        s match {
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   536
          case Name1(a) => List(a)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   537
          case Name2(a) => List(a)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   538
          case Name_Adr1(a, b) => List(a, b)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   539
          case Name_Adr2(a, b) => List(a, b)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   540
          case Name_Adr3(a, b) => List(a, b)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   541
          case Name_Adr4(a, b) => List(a, b)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   542
          case Adr_Name1(b, a) => List(a, b)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   543
          case Adr_Name2(b, a) => List(a, b)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   544
          case Adr1(a) => List(a)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   545
          case Adr2(a) => List(a)
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   546
          case _ => Nil
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   547
        }
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   548
    }
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   549
74923
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   550
    override def message_content(name: String, lines: List[String]): Message =
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   551
    {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   552
      def err(msg: String = ""): Nothing =
74923
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   553
        error("Malformed message: " + name + (if (msg.isEmpty) "" else "\n" + msg))
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   554
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   555
      val (head, body) =
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   556
        try { (Head.get(lines), make_body(Body.get(lines))) }
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   557
        catch { case ERROR(msg) => err(msg) }
72559
274c9986e55b maintain Isabelle mailing list archives;
wenzelm
parents: 72558
diff changeset
   558
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   559
      val date =
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   560
        message_match(head, """<li><em>Date</em>:\s*(.*?)\s*</li>""".r)
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   561
          .map(m => HTML.input(m.group(1))) match
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   562
        {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   563
          case Some(Date_Format(d)) => d
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   564
          case Some(s) => err("Malformed Date: " + quote(s))
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   565
          case None => err("Missing Date")
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   566
        }
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   567
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   568
      val title =
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   569
        make_title(
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   570
          HTML.input(message_match(head, """<li><em>Subject</em>:\s*(.*)</li>""".r)
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   571
            .getOrElse(err("Missing Subject")).group(1)))
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   572
74938
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   573
      def parse_author_info(re: Regex): List[String] =
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   574
        message_match(head, re) match {
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   575
          case None => Nil
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   576
          case Some(m) => Address.parse(m.group(1)).map(a => HTML.input(make_name(a)))
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   577
        }
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   578
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   579
      val author_info =
74938
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   580
        (parse_author_info("""<li><em>From</em>:\s*(.*?)\s*</li>""".r) :::
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   581
          parse_author_info("""<li><em>Reply-to</em>:\s*(.*?)\s*</li>""".r))
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   582
        .distinct.filter(_.nonEmpty)
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   583
f76bf7b5baed more accurate names;
wenzelm
parents: 74937
diff changeset
   584
      if (author_info.isEmpty) err("Malformed author information")
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   585
74934
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   586
      val tags = List(list_name)
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   587
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   588
      Message(name, date, title, standard_author_info(author_info), body, tags)
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   589
    }
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   590
  }
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   591
74930
e9506503efea tuned comments;
wenzelm
parents: 74925
diff changeset
   592
e9506503efea tuned comments;
wenzelm
parents: 74925
diff changeset
   593
  /* isabelle-dev mailing list */
e9506503efea tuned comments;
wenzelm
parents: 74925
diff changeset
   594
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   595
  object Isabelle_Dev extends Archive(Url("https://mailmanbroy.in.tum.de/pipermail/isabelle-dev"))
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   596
  {
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   597
    override def message_regex: Regex = """<LI><A HREF="(\d+\.html)">""".r
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   598
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   599
    private object Head extends Message_Chunk(en = "<!--beginarticle-->")
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   600
    private object Body extends Message_Chunk(bg = "<!--beginarticle-->", en = "<!--endarticle-->")
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   601
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   602
    private object Date_Format
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   603
    {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   604
      val Format = Date.Format("E MMM d H:m:s z uuuu")
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   605
      def unapply(s: String): Option[Date] = Format.unapply(s.replaceAll("""\s+""", " "))
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   606
    }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   607
74923
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   608
    override def message_content(name: String, lines: List[String]): Message =
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   609
    {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   610
      def err(msg: String = ""): Nothing =
74923
e0070487b635 clarified name;
wenzelm
parents: 74922
diff changeset
   611
        error("Malformed message: " + name + (if (msg.isEmpty) "" else "\n" + msg))
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   612
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   613
      val (head, body) =
74924
af954161e1cd misc tuning and clarification;
wenzelm
parents: 74923
diff changeset
   614
        try { (Head.get(lines), make_body(Body.get(lines))) }
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   615
        catch { case ERROR(msg) => err(msg) }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   616
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   617
      val date =
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   618
        message_match(head, """\s*<I>(.*)</I>""".r).map(m => HTML.input(m.group(1))) match {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   619
          case Some(Date_Format(d)) => d
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   620
          case Some(s) => err("Malformed Date: " + quote(s))
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   621
          case None => err("Missing Date")
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   622
        }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   623
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   624
      val (title, author_address) =
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   625
      {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   626
        message_match(head, """TITLE="([^"]+)">(.*)""".r) match {
74931
1753dade9a24 more data integrity: name vs. address;
wenzelm
parents: 74930
diff changeset
   627
          case Some(m) => (make_title(HTML.input(m.group(1))), make_name(HTML.input(m.group(2))))
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   628
          case None => err("Missing TITLE")
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   629
        }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   630
      }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   631
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   632
      val author_name =
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   633
        message_match(head, """\s*<B>(.*)</B>""".r) match {
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   634
          case None => err("Missing author")
74931
1753dade9a24 more data integrity: name vs. address;
wenzelm
parents: 74930
diff changeset
   635
          case Some(m) =>
1753dade9a24 more data integrity: name vs. address;
wenzelm
parents: 74930
diff changeset
   636
            val a = make_name(HTML.input(m.group(1)))
1753dade9a24 more data integrity: name vs. address;
wenzelm
parents: 74930
diff changeset
   637
            if (a == author_address) "" else a
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   638
        }
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   639
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   640
      val author_info = List(author_name, author_address)
74934
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   641
      val tags = List(list_name)
f5ad3214bef4 clarified signature: more operations;
wenzelm
parents: 74933
diff changeset
   642
74936
4c166d510b65 clarified author info and cluster nodes;
wenzelm
parents: 74935
diff changeset
   643
      Message(name, date, title, standard_author_info(author_info), body, tags)
74922
15404e37c127 more mailing list content;
wenzelm
parents: 74921
diff changeset
   644
    }
74921
74655fd58f8e more mailing list content;
wenzelm
parents: 74907
diff changeset
   645
  }
72558
38ebf696fd0c support for Mailman list servers;
wenzelm
parents:
diff changeset
   646
}