]> git.lyx.org Git - lyx.git/blobdiff - lib/generate_contributions.py
Pretty printing
[lyx.git] / lib / generate_contributions.py
index 952c0aaa255ec692092f0994f4b80f071a79e30b..b92042686330801e7aed93889144b3a5597a73ff 100755 (executable)
@@ -21,7 +21,7 @@ $ python generate_contributions.py \
 where the arguments are the names of the generated files.
 '''
 
-import codecs, sys
+import codecs, sys, textwrap
 
 def xml_escape(s):
     s = s.replace("&", "&")
@@ -63,14 +63,14 @@ class contributer:
           return "".join(result)
 
 
-     def as_php_credits(self):
+     def as_php_credits(self, wrapper):
           return '''
 contrib("%s",
         "%s",
         "%s");
 ''' % ( xml_escape(self.name),
         xml_escape(self.contact),
-        xml_escape(self.credit) )
+        "\n".join(wrapper.wrap(xml_escape(self.credit))) )
 
 
      def as_php_blanket(self):
@@ -94,7 +94,43 @@ def error(message):
 
 
 def usage(prog_name):
-     return "Usage: %s <CREDITS> <credits.php> <blanket-permission.php" % prog_name
+     return "Usage: %s <CREDITS> <credits.php> <blanket-permission.php>" % prog_name
+
+
+def collate_incomplete(contributers):
+
+    missing_credit = []
+    missing_licence = []
+    for contributer in contributers:
+          if len(contributer.credit) == 0:
+              missing_credit.append(contributer.name)
+          if len(contributer.licence) == 0:
+              missing_licence.append(contributer.name)
+
+    return '''WARNING!
+The following contributers to not have a CREDITS entry:
+    %s
+
+These ones have no explicit licence statement:
+    %s
+''' % ( ",\n    ".join(missing_credit), ",\n    ".join(missing_licence))
+
+
+def as_txt_credits(contributers):
+     results = []
+
+     for contributer in contributers:
+          if len(contributer.credit) != 0:
+              results.append(contributer.as_txt_credits())
+
+     results.append('''
+
+If your name doesn't appear here although you've done
+something for LyX, or your entry is wrong or incomplete,
+just drop some e-mail to lyx@lyx.org. Thanks.
+''')
+
+     return "".join(results)
 
 
 def header(title, file):
@@ -122,23 +158,6 @@ include("end.php3");
 ?>
 '''
 
-def as_txt_credits(contributers):
-     results = []
-
-     for contributer in contributers:
-          if len(contributer.credit) != 0:
-              results.append(contributer.as_txt_credits())
-
-     results.append('''
-
-If your name doesn't appear here although you've done
-something for LyX, or your entry is wrong or incomplete,
-just drop some e-mail to lyx@lyx.org. Thanks.
-''')
-
-     return "".join(results)
-
-
 def as_php_credits(contributers, file):
      results = []
 
@@ -151,12 +170,16 @@ function contrib($name, $email, $msg) {
 echo "
 
  <dt>
-  <b>${name}</b>";
+  <b>${name}</b>
+";
 
 if (isset($email) && $email != "")
         echo "  <i>&lt;${email}&gt;</i>";
 
-echo " </dt>
+$msg = ereg_replace("\\n *", "\\n  ", ltrim($msg));
+
+echo "
+ </dt>
  <dd>
   ${msg}
  </dd>";
@@ -172,12 +195,13 @@ echo " </dt>
      mailing list. Thanks.
 </p>
 
-<dl>
-<?php''')
+<dl><?php''')
+
+     wrapper = textwrap.TextWrapper(width=60, subsequent_indent="         ")
 
      for contributer in contributers:
           if len(contributer.credit) != 0:
-               results.append(contributer.as_php_credits())
+               results.append(contributer.as_php_credits(wrapper))
 
      results.append('''?>
 
@@ -227,8 +251,7 @@ echo "&quot;
      Gnu General Public Licence</a>, version 2 or later.
 </p>
 
-<dl>
-<?php''')
+<dl><?php''')
 
      for contributer in contributers:
           if contributer.licence == "GPL":
@@ -274,10 +297,13 @@ def main(argv, contributers):
      php_credits = open(argv[2], "w")
      php_credits.write(php_credits_data)
 
-     php_blanket_data = unicode(as_php_blanket(contributers, argv[3])).encode("utf-8") 
+     php_blanket_data = unicode(as_php_blanket(contributers, argv[3])).encode("utf-8")
      php_blanket = open(argv[3], "w")
      php_blanket.write(php_blanket_data)
 
+     warning_data =  unicode(collate_incomplete(contributers) + '\n').encode("utf-8")
+     sys.stderr.write(warning_data)
+
 
 # Store the raw data.
 contributers = [
@@ -360,7 +386,7 @@ contributers = [
                  "Re: Licensing of tex2lyx (and perhaps LyX itself?)",
                  "m=110907078027047",
                  "22 February 2005",
-                 u"Improvements to user interface (menus and keyhandling) including configurabletoolbar, and a few other (not so) minor things, like rewriting most of the LyX kernel. Also current source maintainer"),
+                 u"Improvements to user interface (menus and keyhandling) including a configurable toolbar and a few other (not so) minor things, like rewriting most of the LyX kernel. Also current source maintainer"),
 
      contributer(u"Alfredo Braunstein",
                  "abraunst () lyx ! org",
@@ -384,7 +410,7 @@ contributers = [
                  "Re: The LyX licence",
                  "m=110908472818670",
                  "22 February 2005",
-                 u"Ported John Levon's original 'change tracking' code to later versions of LyX.Numerous bug fixes thereof."),
+                 u"Ported John Levon's original 'change tracking' code to later versions of LyX. Numerous bug fixes thereof."),
 
      contributer(u"Francesc Burrull i Mestres",
                  "fburrull () mat ! upc ! es",
@@ -480,7 +506,7 @@ contributers = [
                  "Re: The LyX licence",
                  "m=110959835300777",
                  "28 February 2005",
-                 u"Improvements to lyxserver; LyX-Client perl package"),
+                 u"Improvements to lyxserver"),
 
      contributer(u"Hartmut Goebel",
                  "h.goebel () crazy-compilers ! com",
@@ -728,7 +754,7 @@ contributers = [
                  "Re: The LyX licence",
                  "m=110911176213928",
                  "22 February 2005",
-                 u"Improvements to find&replace popup"),
+                 u"Improvements to the find&replace dialog"),
 
      contributer(u"Pablo De Napoli",
                  "pdenapo () mate ! dm ! uba ! ar",
@@ -808,7 +834,7 @@ contributers = [
                  "Re: The LyX licence",
                  "m=111121553103800",
                  "19 March 2005",
-                 u"heavy mathed testing provided siamltex document class"),
+                 u"heavy mathed testing; provided siamltex document class"),
 
      contributer(u"Bernhard Psaier",
                  "",
@@ -859,11 +885,11 @@ contributers = [
                  u"Creator of the native port of LyX to Windows"),
 
      contributer(u"Bernd Rellermeyer",
-                 "100.41728 () germanynet ! de",
-                 "",
-                 "",
-                 "",
-                 "",
+                 "bernd.rellermeyer () arcor ! de",
+                 "GPL",
+                 "Re: The LyX licence",
+                 "m=111317142419908",
+                 "10 April 2005",
                  u"Support for Koma-Script family of classes"),
 
      contributer(u"Michael Ressler",
@@ -1040,7 +1066,7 @@ contributers = [
                  "Re: The LyX licence",
                  "m=110907543900367",
                  "22 February 2005",
-                 u"support for optional argument in sections/captions svjour/svjog, egs and llncs document classes Lot of bug hunting (and fixing!)"),
+                 u"support for optional argument in sections/captions svjour/svjog, egs and llncs document classes. Lot of bug hunting (and fixing!)"),
 
      contributer(u"Jürgen Vigna",
                  "jug () lyx ! org",
@@ -1048,7 +1074,7 @@ contributers = [
                  "Re: Licensing of tex2lyx (and perhaps LyX itself?)",
                  "m=110899839906262",
                  "21 February 2005",
-                 u"complete rewrite of the tabular, text inset fax- and Ascii-Export support iletter and dinbrief support"),
+                 u"complete rewrite of the tabular, text inset; fax- and Ascii-Export support; iletter and dinbrief support"),
 
      contributer(u"Pauli Virtanen",
                  "pauli.virtanen () hut ! fi",