Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13332/Lib Modified Files: optparse.py Log Message: Fix support for the "prog" keyword to the OptionParser constructor, as well as directly setting the .prog attribute (which should be supported based on the class docstring). Closes SF bug #850964. Index: optparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/optparse.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** optparse.py 21 Mar 2004 19:28:48 -0000 1.7 --- optparse.py 1 Apr 2004 07:40:35 -0000 1.8 *************** *** 1026,1029 **** --- 1026,1034 ---- self.values = None + def _get_prog_name(self): + if self.prog: + return self.prog + else: + return get_prog_name() # -- Simple modifier methods --------------------------------------- *************** *** 1289,1298 **** """ self.print_usage(sys.stderr) ! sys.exit("%s: error: %s" % (get_prog_name(), msg)) def get_usage (self): if self.usage: return self.formatter.format_usage( ! self.usage.replace("%prog", get_prog_name())) else: return "" --- 1294,1303 ---- """ self.print_usage(sys.stderr) ! sys.exit("%s: error: %s" % (self._get_prog_name(), msg)) def get_usage (self): if self.usage: return self.formatter.format_usage( ! self.usage.replace("%prog", self._get_prog_name())) else: return "" *************** *** 1312,1316 **** def get_version (self): if self.version: ! return self.version.replace("%prog", get_prog_name()) else: return "" --- 1317,1321 ---- def get_version (self): if self.version: ! return self.version.replace("%prog", self._get_prog_name()) else: return ""
participants (1)
-
fdrake@users.sourceforge.net