Changeset 3337

Show
Ignore:
Timestamp:
02/18/08 18:11:35 (17 years ago)
Author:
jerome
Message:

Added some utility methods.
Made generic --logo help not depend anymore on the pkbanner's
command context.

Location:
pykota/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkbanner

    r3335 r3337  
    234234                            dest="logo", 
    235235                            default=u"/usr/share/pykota/logos/pykota.jpeg", 
    236                             help=_("The image to use as the banner's logo. The logo will be drawn at the center top of the page. The default logo is %default")) 
     236                            help=_("The image to use as a logo. The logo will be drawn at the center top of the page. The default logo is %default")) 
    237237    parser.add_option("-p", "--pagesize", 
    238238                            type="string", 
  • pykota/trunk/pykota/commandline.py

    r3335 r3337  
    4444        loginvalidparam(opt, value, option.default, \ 
    4545                        _("Allowed range is (0..99)")) 
     46        setattr(optionparser.values, option.dest, option.default) 
     47    else :     
     48        setattr(optionparser.values, option.dest, value) 
     49         
     50def checkandset_positiveint(option, opt, value, optionparser) :     
     51    """Checks if an option argument is a positive integer and validates the option if it is the case.""" 
     52    if not (value >= 0) : 
     53        loginvalidparam(opt, value, option.default, \ 
     54                        _("Value must be positive")) 
     55        setattr(optionparser.values, option.dest, option.default) 
     56    else :     
     57        setattr(optionparser.values, option.dest, value) 
     58         
     59def checkandset_positivefloat(option, opt, value, optionparser) :     
     60    """Checks if an option argument is a positive integer and validates the option if it is the case.""" 
     61    if not (value >= 0.0) : 
     62        loginvalidparam(opt, value, option.default, \ 
     63                        _("Value must be positive")) 
    4664        setattr(optionparser.values, option.dest, option.default) 
    4765    else :