Index: /pykota/trunk/setup.py
===================================================================
--- /pykota/trunk/setup.py (revision 1758)
+++ /pykota/trunk/setup.py (revision 1771)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.53  2004/10/04 21:25:29  jalet
+# dumpykota can now output datas in the XML format
+#
 # Revision 1.52  2004/09/30 09:52:45  jalet
 # Initial release of autopykota. Reading help or manpage is greatly
@@ -429,4 +432,5 @@
                        ("Python-OSD", "pyosd", "Python-OSD is recommended if you plan to use the X Window On Screen Display\nprint quota reminder named pykosd."),
                        ("Python-SNMP", "pysnmp", "Python-SNMP is recommended if you plan to use hardware\naccounting with printers which support SNMP.\nSee http://pysnmp.sf.net"),
+                       ("Python-JAXML", "jaxml", "Python-JAXML is recommended if you plan to dump datas in the XML format.\nSee http://www.librelogiciel.com/software/"),
                      ]
     commandstocheck = [("SNMP Tools", "snmpget", "SNMP Tools are needed if you want to use SNMP enabled printers."), ("Netatalk", "pap", "Netatalk is needed if you want to use AppleTalk enabled printers.")]
Index: /pykota/trunk/README
===================================================================
--- /pykota/trunk/README (revision 1744)
+++ /pykota/trunk/README (revision 1771)
@@ -210,6 +210,9 @@
     - Python v2.1 or above
     - eGenix' mxDateTime Python extension
-    - SNMP tools (specifically the snmpget command) if you plan to
-      request your printer's lifetime page counter via SNMP.
+    - The JAXML Python module to be able to dump datas in the XML format.
+    - The Python-SNMP module to query printers for their page counter.
+    - The Python-OSD module to use the graphical print quota reminder.
+    - SNMP tools (specifically the snmpget command) if you prefer to
+      use your own script to request query printers.
     - Netatalk (specifically the pap command) if you plan to
       request your printer's lifetime page counter via AppleTalk.
@@ -221,7 +224,7 @@
       if you plan to use OpenLDAP as the Quota Storage backend.
     
-  On Intel i386 architecture, and for performance reasons if you 
-  print in PCL5 or PCL6 format, it is strongly suggested that you  
-  install the Python accelerator Psyco, available at :
+  On Intel i386 architecture, and for performance reasons, it is
+  strongly suggested that you install the Python accelerator Psyco, 
+  available at :
   
       http://psyco.sourceforge.net
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 1761)
+++ /pykota/trunk/pykota/version.py (revision 1771)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.20alpha19_unofficial"
+__version__ = "1.20alpha20_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: /pykota/trunk/bin/dumpykota
===================================================================
--- /pykota/trunk/bin/dumpykota (revision 1724)
+++ /pykota/trunk/bin/dumpykota (revision 1771)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.7  2004/10/04 21:25:29  jalet
+# dumpykota can now output datas in the XML format
+#
 # Revision 1.6  2004/09/15 18:28:41  jalet
 # Updated help for dumpykota
@@ -51,4 +54,13 @@
 import os
 import pwd
+
+try :
+    import jaxml
+except ImportError :    
+    sys.stderr.write("The jaxml Python module is not installed. XML output is disabled.\n")
+    sys.stderr.write("Download jaxml from http://www.librelogiciel.com/software/ or from your Debian archive of choice\n")
+    hasJAXML = 0
+else :    
+    hasJAXML = 1
 
 from pykota import version
@@ -93,4 +105,21 @@
                          - ssv : separate datas with semicolons
                          - tsv : separate datas with tabs
+                         - xml : dump data as XML
+                         
+  -o | --output fname  All datas will be dumped to the file instead of
+                       to the standard output. The special '-' filename
+                       is the default value and means stdout.
+                       WARNING : existing files are truncated !
+  
+Examples :
+
+  $ dumpykota --data history --format csv >myfile.csv
+  
+  This dumps the history in a comma separated values file, for possible
+  use in a spreadsheet.
+  
+  $ dumpykota --data users --format xml -o users.xml
+  
+  Dumps all users datas to the users.xml file.
   
 This program is free software; you can redistribute it and/or modify
@@ -131,10 +160,26 @@
                            "ssv",
                            "tsv",
+                           "xml",
                          ] :
             raise PyKotaToolError, _("Invalid modifier [%s] for --format command line option, see help.") % datatype
             
+        if (format == "xml") and not hasJAXML :
+            raise PyKotaToolError, _("XML output is disabled because the jaxml module is not available.")
+            
         entries = getattr(self.storage, "extract%s" % datatype.title())()    
-        if entries is not None :
-            return getattr(self, "dump%s" % format.title())(entries)
+        if entries :
+            mustclose = 0    
+            if options["output"].strip() == "-" :    
+                self.outfile = sys.stdout
+            else :    
+                self.outfile = open(options["output"], "w")
+                mustclose = 1
+                
+            retcode = getattr(self, "dump%s" % format.title())(entries, datatype)
+            
+            if mustclose :
+                self.outfile.close()
+                
+            return retcode    
         return 0
         
@@ -144,5 +189,5 @@
             line = separator.join([ '"%s"' % field for field in entry ])
             try :
-                print line
+                self.outfile.write("%s\n" % line)
             except IOError, msg :    
                 sys.stderr.write("%s : %s\n" % (_("PyKota data dumper failed : I/O error"), msg))
@@ -150,15 +195,31 @@
         return 0        
         
-    def dumpCsv(self, entries) :    
+    def dumpCsv(self, entries, dummy) :    
         """Dumps datas with a comma as the separator."""
         return self.dumpWithSeparator(",", entries)
                            
-    def dumpSsv(self, entries) :    
+    def dumpSsv(self, entries, dummy) :    
         """Dumps datas with a comma as the separator."""
         return self.dumpWithSeparator(";", entries)
                            
-    def dumpTsv(self, entries) :    
+    def dumpTsv(self, entries, dummy) :    
         """Dumps datas with a comma as the separator."""
         return self.dumpWithSeparator("\t", entries)
+        
+    def dumpXml(self, entries, datatype) :    
+        """Dumps datas as XML."""
+        x = jaxml.XML_document(encoding="UTF-8")
+        x.pykota(version=version.__version__)
+        x.dump(storage=self.config.getStorageBackend()["storagebackend"], type=datatype)
+        headers = entries[0]
+        for entry in entries[1:] :
+            x._push()
+            x.entry()
+            for i in range(len(entry)) :
+                value = entry[i]
+                strvalue = str(value).decode(self.getCharset()).encode("UTF-8")
+                x.attribute(strvalue, type=type(value).__name__, name=headers[i])
+            x._pop()    
+        x._output(self.outfile)
                            
 if __name__ == "__main__" : 
@@ -167,7 +228,8 @@
         defaults = { \
                      "format" : "csv", \
+                     "output" : "-", \
                    }
-        short_options = "vhd:f:"
-        long_options = ["help", "version", "data=", "format="]
+        short_options = "vhd:f:o:"
+        long_options = ["help", "version", "data=", "format=", "output="]
         
         # Initializes the command line tool
@@ -182,4 +244,5 @@
         options["data"] = options["d"] or options["data"]
         options["format"] = options["f"] or options["format"] or defaults["format"]
+        options["output"] = options["o"] or options["output"] or defaults["output"]
         
         if options["help"] :
Index: /pykota/trunk/man/dumpykota.1
===================================================================
--- /pykota/trunk/man/dumpykota.1 (revision 1758)
+++ /pykota/trunk/man/dumpykota.1 (revision 1771)
@@ -1,8 +1,8 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.33.
-.TH DUMPYKOTA "1" "September 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
+.TH DUMPYKOTA "1" "October 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"
 .SH NAME
-dumpykota \- manual page for dumpykota 1.20alpha18_unofficial
+dumpykota \- manual page for dumpykota 1.20alpha20_unofficial
 .SH DESCRIPTION
-dumpykota v1.20alpha18_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
+dumpykota v1.20alpha20_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres
 .PP
 Dumps PyKota database's content.
@@ -45,4 +45,22 @@
 - ssv : separate datas with semicolons
 - tsv : separate datas with tabs
+- xml : dump data as XML
+.TP
+\fB\-o\fR | \fB\-\-output\fR fname
+All datas will be dumped to the file instead of
+to the standard output. The special '-' filename
+is the default value and means stdout.
+WARNING : existing files are truncated !
+.PP
+Examples :
+.IP
+\f(CW$ dumpykota --data history --format csv >myfile.csv\fR
+.IP
+This dumps the history in a comma separated values file, for possible
+use in a spreadsheet.
+.IP
+\f(CW$ dumpykota --data users --format xml -o users.xml\fR
+.IP
+Dumps all users datas to the users.xml file.
 .PP
 This program is free software; you can redistribute it and/or modify
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 1769)
+++ /pykota/trunk/NEWS (revision 1771)
@@ -22,4 +22,8 @@
 PyKota NEWS :
 
+    - 1.20alpha20 :
+    
+        - dumpykota can now output XML.
+        
     - 1.20alpha19 :
     
