From d926e748839a1b224070eab5d3836f82a9774239 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 13 Apr 2011 21:59:26 +0000 Subject: [PATCH] Initial LogRotateGetopts.py git-svn-id: http://svn.brehm-online.com/svn/my-stuff/python/PyLogrotate/trunk@197 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- LogRotateGetopts.py | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 LogRotateGetopts.py diff --git a/LogRotateGetopts.py b/LogRotateGetopts.py new file mode 100755 index 0000000..808794f --- /dev/null +++ b/LogRotateGetopts.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# $Id$ +# $URL$ + +''' +@author: Frank Brehm +@contact: frank@brehm-online.com +@license: GPL3 +@copyright: (c) 2010-2011 by Frank Brehm, Berlin +@version: 0.0.1 +@summary: Option parser for Python logrotating +''' + +import re + +revision = '$Revision$' +revision = re.sub( r'\$', '', revision ) +revision = re.sub( r'Revision: ', r'r', revision ) +revision = re.sub( r'\s*$', '', revision ) + +__author__ = 'Frank Brehm' +__copyright__ = '(C) 2011 by Frank Brehm, Berlin' +__contact__ = 'frank@brehm-online.com' +__version__ = '0.0.1 ' + revision +__license__ = 'GPL3' + + +#======================================================================== + +class LogrotateOptParser(object): + ''' + Class for parsing commandline options of Python logrotating. + + @author: Frank Brehm + @contact: frank@brehm-online.com + ''' + + #------------------------------------------------------- + def __init__( self, prog = '%prog', + version = None, + description = '', + usage = 'Usage: %s [options]', + ): + ''' + Costructor. + @param prog: The name of the calling process (e.g. sys.argv[0]) + @type prog: str + @param version: The version string to use + @type version: str + @param description: The Description the process should use + @type description: str + @param usage: An usage string fro the help screen, must have a '%s' for the program name + @type usage: str + @return: None + ''' + + self.prog = prog + self.version = version + self.description = description + self.usage = usage %(prog) + + self.options = None + self.args = None + self.__options_set = False + self.__action_set = None + self.parsed = False + + self.parser = OptionParser( + prog = self.prog, + version = self.version, + description = self.description, + usage = self.usage + ) + + + +#======================================================================== + +if __name__ == "__main__": + main() + + +#======================================================================== + +# vim: fileencoding=utf-8 filetype=python ts=4 expandtab -- 2.39.5