SF #642236, optparse LaTeX docs by Johannes Gijsbers

This commit is contained in:
Neal Norwitz 2003-01-06 16:51:37 +00:00
parent 11f89b75e1
commit 488609e43a
6 changed files with 1821 additions and 0 deletions

20
Doc/lib/required_1.py Executable file
View file

@ -0,0 +1,20 @@
import optparse
class OptionParser (optparse.OptionParser):
def check_required (self, opt):
option = self.get_option(opt)
# Assumes the option's 'default' is set to None!
if getattr(self.values, option.dest) is None:
self.error("%s option not supplied" % option)
parser = OptionParser()
parser.add_option("-v", action="count", dest="verbose")
parser.add_option("-f", "--file", default=None)
(options, args) = parser.parse_args()
print "verbose:", options.verbose
print "file:", options.file
parser.check_required("-f")