pvl/args.py
changeset 34 603a823bf5df
parent 29 8fcb140f1ee0
equal deleted inserted replaced
33:6779237c43a4 34:603a823bf5df
    12 
    12 
    13 import logging; log = logging.getLogger('pvl.args')
    13 import logging; log = logging.getLogger('pvl.args')
    14 
    14 
    15 CONFDIR = '/etc/pvl'
    15 CONFDIR = '/etc/pvl'
    16 
    16 
    17 def parser (parser, setuid=None) :
    17 def parser (parser, setuid=None, config=True) :
    18     """
    18     """
    19         Return an optparse.OptionGroup.
    19         Return an optparse.OptionGroup.
    20     """
    20     """
    21 
    21 
    22     if setuid is None :
    22     if setuid is None :
    30     general.add_option('-v', '--verbose',   dest='loglevel', action='store_const', const=logging.INFO,  help="More output")
    30     general.add_option('-v', '--verbose',   dest='loglevel', action='store_const', const=logging.INFO,  help="More output")
    31     general.add_option('-D', '--debug',     dest='loglevel', action='store_const', const=logging.DEBUG, help="Even more output")
    31     general.add_option('-D', '--debug',     dest='loglevel', action='store_const', const=logging.DEBUG, help="Even more output")
    32     general.add_option('--log-file',                                                                    help="Log to file")
    32     general.add_option('--log-file',                                                                    help="Log to file")
    33     general.add_option('--debug-module',    action='append', metavar='MODULE', 
    33     general.add_option('--debug-module',    action='append', metavar='MODULE', 
    34             help="Enable logging for the given logger/module name")
    34             help="Enable logging for the given logger/module name")
    35 
    35     
    36     parser.add_option('-c', '--config',    metavar='PATH',      action='append',
    36     if config:
    37             help="Read option defaults from config")
    37         parser.add_option('--config',           metavar='PATH',      action='append',
    38     parser.add_option('--config-encoding',  metavar='CHARSET',  default='utf-8',
    38                 help="Read option defaults from config")
    39             help="Unicode decoding for config file")
    39         parser.add_option('--config-encoding',  metavar='CHARSET',  default='utf-8',
    40 
    40                 help="Unicode decoding for config file")
    41    
    41    
    42     if setuid :
    42     if setuid :
    43         general.add_option('--uid',             help="Change uid")
    43         general.add_option('--uid',             help="Change uid")
    44         general.add_option('--gid',             help="Change gid")
    44         general.add_option('--gid',             help="Change gid")
    45 
    45