Index: pykota/trunk/pykota/pdfutils.py
===================================================================
--- pykota/trunk/pykota/pdfutils.py (revision 3335)
+++ pykota/trunk/pykota/pdfutils.py (revision 3335)
@@ -0,0 +1,37 @@
+# -*- coding: UTF-8 -*-
+#
+# PyKota : Print Quotas for CUPS
+#
+# (c) 2003, 2004, 2005, 2006, 2007, 2008 Jerome Alet <alet@librelogiciel.com>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# $Id$
+#
+
+"""This module contains helper methods for PDF related work."""
+
+def getPageSize(pgsize) :
+    """Returns the correct page size or None if not found."""
+    try :
+        import reportlab.lib.pagesizes as sizes
+    except ImportError :    
+        pass
+    else :    
+        try :
+            return getattr(sizes, pgsize.upper(), getattr(sizes, 
+                                                          pgsize.lower(), 
+                                                          None))
+        except UnicodeError :            
+            pass
+    return None        
Index: pykota/trunk/pykota/commandline.py
===================================================================
--- pykota/trunk/pykota/commandline.py (revision 3316)
+++ pykota/trunk/pykota/commandline.py (revision 3335)
@@ -28,4 +28,23 @@
 
 from pykota import version
+from pykota.utils import loginvalidparam
+
+def checkandset_pagesize(option, opt, value, optionparser) :
+    """Checks and sets the page size."""
+    from pykota.pdfutils import getPageSize
+    if getPageSize(value) is None :
+        loginvalidparam(opt, value, option.default)
+        setattr(optionparser.values, option.dest, option.default)
+    else :    
+        setattr(optionparser.values, option.dest, value)
+    
+def checkandset_savetoner(option, opt, value, optionparser) :    
+    """Checks and sets the save toner value."""
+    if (value < 0.0) or (value > 99.0) :
+        loginvalidparam(opt, value, option.default, \
+                        _("Allowed range is (0..99)"))
+        setattr(optionparser.values, option.dest, option.default)
+    else :    
+        setattr(optionparser.values, option.dest, value)
 
 class PyKotaOptionParser(optparse.OptionParser) :
Index: pykota/trunk/bin/pkbanner
===================================================================
--- pykota/trunk/bin/pkbanner (revision 3332)
+++ pykota/trunk/bin/pkbanner (revision 3335)
@@ -47,25 +47,13 @@
     
 import pykota.appinit
-from pykota.utils import run, loginvalidparam
-from pykota.commandline import PyKotaOptionParser
-
+from pykota.utils import run
+from pykota.commandline import PyKotaOptionParser, \
+                               checkandset_pagesize, \
+                               checkandset_savetoner
+from pykota.pdfutils import getPageSize
 from pykota.errors import PyKotaToolError
 from pykota.tool import Tool
 from pykota import version
 
-def getPageSize(pgsize) :
-    """Returns the correct page size or None if not found."""
-    try :
-        try :
-            return getattr(reportlab.lib.pagesizes, pgsize.upper())
-        except AttributeError :    
-            try :
-                return getattr(reportlab.lib.pagesizes, pgsize.lower())
-            except AttributeError :
-                pass
-    except UnicodeError :            
-        pass
-    return None        
-    
 class PyKotaBanner(Tool) :        
     """A class for pkbanner."""
@@ -241,21 +229,4 @@
 
 if __name__ == "__main__" :
-    def checkandset_pagesize(option, opt, value, optionparser) :
-        """Checks and sets the page size."""
-        if getPageSize(value) is None :
-            loginvalidparam(opt, value, option.default)
-            setattr(optionparser.values, option.dest, option.default)
-        else :    
-            setattr(optionparser.values, option.dest, value)
-        
-    def checkandset_savetoner(option, opt, value, optionparser) :    
-        """Checks and sets the save toner value."""
-        if (value < 0.0) or (value > 99.0) :
-            loginvalidparam(opt, value, option.default, \
-                            _("Allowed range is (0..99)"))
-            setattr(optionparser.values, option.dest, option.default)
-        else :    
-            setattr(optionparser.values, option.dest, value)
-        
     # TODO : --papertray : to print banners on a different paper (colored for example)
     parser = PyKotaOptionParser(description=_("Banner generator for PyKota."))
