summaryrefslogtreecommitdiffstats
path: root/Doc/lib/required_1.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-01-06 16:51:37 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-01-06 16:51:37 (GMT)
commit488609e43af797bcc23beb5d8d20731a45d8a982 (patch)
tree871ee52d3cf56d47225a6c1924c1bdb1b4a4d9dc /Doc/lib/required_1.py
parent11f89b75e1445e430964bf71047f3a7419c59fb4 (diff)
downloadcpython-488609e43af797bcc23beb5d8d20731a45d8a982.zip
cpython-488609e43af797bcc23beb5d8d20731a45d8a982.tar.gz
cpython-488609e43af797bcc23beb5d8d20731a45d8a982.tar.bz2
SF #642236, optparse LaTeX docs by Johannes Gijsbers
Diffstat (limited to 'Doc/lib/required_1.py')
-rwxr-xr-xDoc/lib/required_1.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Doc/lib/required_1.py b/Doc/lib/required_1.py
new file mode 100755
index 0000000..44d5b30
--- /dev/null
+++ b/Doc/lib/required_1.py
@@ -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")