commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/reports/samples/mailmerge README mailmerge...


From: Jason Cater
Subject: gnue/reports/samples/mailmerge README mailmerge...
Date: Fri, 05 Oct 2001 00:31:49 -0400

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/10/05 00:31:49

Modified files:
        reports/samples/mailmerge: README mailmerge.py merge-latex 
Added files:
        reports/samples/mailmerge: merge-rtf 

Log message:
        added RTF merge capability; improved RE support; misc changes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/samples/mailmerge/merge-rtf?cvsroot=OldCVS&rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/samples/mailmerge/README.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/samples/mailmerge/mailmerge.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/reports/samples/mailmerge/merge-latex.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gnue/reports/samples/mailmerge/README
diff -u gnue/reports/samples/mailmerge/README:1.4 
gnue/reports/samples/mailmerge/README:1.5
--- gnue/reports/samples/mailmerge/README:1.4   Thu Oct  4 23:16:19 2001
+++ gnue/reports/samples/mailmerge/README       Fri Oct  5 00:31:49 2001
@@ -42,3 +42,34 @@
 This works with LaTex files created with the "Save As" (LaTex format) 
 commands of AbiWord and KWord. Your mileage may vary. 
 
+NOTE: This script works using a simple Regular Expression... IT DOES NOT
+  ACTUALLY PARSE THE LaTeX FORMAT!  As such, there are bound to be examples
+  where this script does not work.
+
+
+merge-rtf
+---------
+
+To test the RTF merge, type:
+
+  $ ./merge-rtf gnue-intro-letter.abiword.rtf < records.xml > sample.rtf
+
+This runs merge-latex using the AbiWord "Save As RTF" document
+gnue-intro-letter.abiword.rtf.  The XML file "records.xml" is used
+as the input stream.  This create a LaTex output file called sample.tex.
+If all goes well, you should be able to run sample.tex with the latex
+command or open sample.tex with any LaTex importer (e.g., AbiWord & KWord)
+
+How it works:
+The merge-rtf searches for the first \pard{ and treats it as the beginning.
+Everything afterwards is treated as a repeatable section. If multiple
+records exist in the mailmerge, then this repeatable section has a \Page
+added between each instance.
+
+This works with RTF files created with the "Save As" (RTF format)
+commands of AbiWord and KWord. Your mileage may vary.
+
+NOTE: This script works using a simple Regular Expression... IT DOES NOT
+  ACTUALLY PARSE THE RTF FORMAT!  As such, there are bound to be examples
+  where this script does not work.   
+
Index: gnue/reports/samples/mailmerge/mailmerge.py
diff -u gnue/reports/samples/mailmerge/mailmerge.py:1.2 
gnue/reports/samples/mailmerge/mailmerge.py:1.3
--- gnue/reports/samples/mailmerge/mailmerge.py:1.2     Thu Oct  4 23:16:19 2001
+++ gnue/reports/samples/mailmerge/mailmerge.py Fri Oct  5 00:31:49 2001
@@ -29,7 +29,7 @@
 # Not intended to be directly run. Use merge-* instead.
 #
 
-import string, re
+import string, sys, re
 from xml.sax import saxlib, saxexts
 
 class MergeBase(saxlib.HandlerBase):
@@ -37,17 +37,17 @@
   NEWPAGE = "\p"
   HEAD_DELIMITER = r"^"
   TAIL_DELIMITER = r"$"
+  REGEX = r"\A(.*"            \
+          + HEAD_DELIMITER \
+          + r")(.+)("           \
+          + TAIL_DELIMITER \
+          + r".*)\Z"
+
   COMMENT_BEGIN = "#"
   COMMENT_END = "\n"
   MULTILINE_COMMENTS = 0
 
   def __init__(self):
-    self.REGEX = r"\A(.*"            \
-          + self.HEAD_DELIMITER \
-          + r")(.+)("           \
-          + self.TAIL_DELIMITER \
-          + r".*)\Z"
-
     self.fieldre = re.compile("%s(\\w+)%s" % \
           (self.FIELD_ENCLOSURE, self.FIELD_ENCLOSURE))
 
@@ -84,6 +84,7 @@
     header, self.repeating, footer = reg.groups()
     self.output = output
     self.recordCount = 1
+    self.newPage = 0
 
     output.write(header)
     self.printComment(output,
@@ -110,6 +111,9 @@
       self.values[string.lower(attrs['name'])] = attrs['value']
     elif name == "record":
       self.values = {}
+      if self.newPage:
+        self.output.write(self.NEWRECORD)
+      self.newPage = 1
 
   def characters(self, ch, start, length):
     pass
Index: gnue/reports/samples/mailmerge/merge-latex
diff -u gnue/reports/samples/mailmerge/merge-latex:1.2 
gnue/reports/samples/mailmerge/merge-latex:1.3
--- gnue/reports/samples/mailmerge/merge-latex:1.2      Thu Oct  4 23:16:19 2001
+++ gnue/reports/samples/mailmerge/merge-latex  Fri Oct  5 00:31:49 2001
@@ -37,12 +37,16 @@
   NAME = "LaTex"
 
   # What "command" separates new records?
-  NEWRECORD = "\\NewPage\n"
+  NEWRECORD = "\\newpage\n"
 
   # The regex description of the beginning and end of the repeatable sections
-  # (Note, these are exclusive boundaries!)
   HEAD_DELIMITER = r"\\begin\{document\}" + "\n"
   TAIL_DELIMITER = r"\\end\{document\}" + "\n"
+  REGEX = r"\A(.*"            \
+          + HEAD_DELIMITER \
+          + r")(.+)("           \
+          + TAIL_DELIMITER \
+          + r".*)\Z"
 
   # Comments...
   COMMENTABLE = 1        # Does this output format support comments?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]