Index: pykota/trunk/bin/edpykota
===================================================================
--- pykota/trunk/bin/edpykota (revision 1956)
+++ pykota/trunk/bin/edpykota (revision 1967)
@@ -24,4 +24,8 @@
 #
 # $Log$
+# Revision 1.83  2004/12/02 21:24:50  jalet
+# Integrated the patch by Wilson Roberto Afonso and Matt Hyclak to allow
+# edpykota to accept the -U | --used value command line option.
+#
 # Revision 1.82  2004/11/22 21:53:38  jalet
 # Added the reject_unknown directive to pykota.conf to reject user/group
@@ -362,5 +366,5 @@
   -R | --hardreset     Resets the actual and life time page counters
                        for the user or group to zero on the specified 
-                       printers. 
+                       printers. This is a shortcut for '--used 0'.
                        
   -l | --limitby l     Choose if the user/group is limited in printing                     
@@ -384,5 +388,15 @@
   
   -H | --hardlimit hl  Sets the quota hard limit to hl pages.
-  
+
+  -U | --used usage    Sets the pagecounters for the user to usage pages;
+                       useful for migrating users from a different system
+                       where they have already used some pages. Actual
+                       and Life Time page counters may be increased or decreased
+                       if usage is prefixed with + or -.
+                       WARNING : BOTH page counters are modified in all cases,
+                       so be careful.
+                       NB : if 'usage' equals '0', then the action taken is
+                       the same as if --hardreset was used.
+
   user1 through userN and group1 through groupN can use wildcards
   if the --add option is not set.
@@ -482,5 +496,14 @@
         suffix = (options["groups"] and "Group") or "User"        
         
-        softlimit = hardlimit = None    
+        softlimit = hardlimit = None
+
+        used = options["used"]
+        if used :
+            used = used.strip()
+            try :
+                int(used)
+            except ValueError :
+                raise PyKotaToolError, _("Invalid used value %s.") % used
+
         if not options["noquota"] :
             if options["softlimit"] :
@@ -668,6 +691,8 @@
                         if options["reset"] :
                             entrypquota.reset()
-                        elif options["hardreset"] :    
+                        if options["hardreset"] :    
                             entrypquota.hardreset()
+                        if options["used"] :
+                            entrypquota.setUsage(used)
                             
                         if balance :
@@ -692,9 +717,4 @@
                                 else :
                                     self.printInfo(_("Group %s not found in the PyKota Storage.") % groupname)
-                                    
-                    # This line disabled to prevent sending of unwanted email                 
-                    # messages if quota is reached at creation/modification time.
-                    # The check will be done at print time anyway.
-                    # getattr(self, "warn%sPQuota" % suffix)(entrypquota)    
                         
         # Now delete what has to be deleted                
@@ -708,6 +728,6 @@
                      "printer" : "*", \
                    }
-        short_options = "vhdc:l:b:i:naugrp:P:S:H:G:R"
-        long_options = ["help", "version", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "hardreset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups="]
+        short_options = "vhdc:l:b:i:naugrp:P:S:H:G:RU:"
+        long_options = ["help", "version", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "hardreset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups=", "used="]
         
         # Initializes the command line tool
@@ -736,4 +756,5 @@
         options["pgroups"] = options["G"] or options["pgroups"]
         options["hardreset"] = options["R"] or options["hardreset"] 
+        options["used"] = options["U"] or options["used"]
         
         if options["help"] :
@@ -749,5 +770,5 @@
         elif options["noquota"] and (options["prototype"] or options["hardlimit"] or options["softlimit"]) :
             raise PyKotaToolError, _("incompatible options, see help.")
-        elif options["groups"] and (options["balance"] or options["ingroups"]) :
+        elif options["groups"] and (options["balance"] or options["ingroups"] or options["used"] or options["reset"] or options["hardreset"]) :
             raise PyKotaToolError, _("incompatible options, see help.")
         else :
Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 1966)
+++ pykota/trunk/NEWS (revision 1967)
@@ -22,4 +22,10 @@
 PyKota NEWS :
 
+    - 1.21alpha11 :
+    
+        - edpkota now accepts the -U | --used value command line argument
+          to preset the page counters to an initial value. Thanks to
+          Wilson Roberto Afonso and Matt Hyclak for the patch.
+          
     - 1.21alpha10 :
     
Index: pykota/trunk/pykota/storage.py
===================================================================
--- pykota/trunk/pykota/storage.py (revision 1875)
+++ pykota/trunk/pykota/storage.py (revision 1967)
@@ -22,4 +22,8 @@
 #
 # $Log$
+# Revision 1.66  2004/12/02 21:24:50  jalet
+# Integrated the patch by Wilson Roberto Afonso and Matt Hyclak to allow
+# edpykota to accept the -U | --used value command line option.
+#
 # Revision 1.65  2004/10/25 14:12:25  jalet
 # For URGENT legal reasons (Italy), a new "privacy" directive was added to pykota.conf
@@ -439,4 +443,15 @@
         self.DateLimit = None
         
+    def setUsage(self, used) :
+        """Sets the PageCounter and LifePageCounter to used, or if used is + or - prefixed, changes the values of {Life,}PageCounter by that amount."""
+        vused = int(used)
+        if used.startswith("+") or used.startswith("-") :
+           self.parent.increaseUserPQuotaPagesCounters(self, vused)
+           self.PageCounter += vused
+           self.LifePageCounter += vused
+        else :
+           self.parent.writeUserPQuotaPagesCounters(self, vused, vused)
+           self.PageCounter = self.LifePageCounter = vused
+
     def reset(self) :    
         """Resets page counter to 0."""
Index: pykota/trunk/pykota/version.py
===================================================================
--- pykota/trunk/pykota/version.py (revision 1966)
+++ pykota/trunk/pykota/version.py (revision 1967)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.21alpha10_unofficial"
+__version__ = "1.21alpha11_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
