summaryrefslogtreecommitdiffstats
path: root/Doc/lib/caseless.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-08-15 14:27:07 (GMT)
committerGeorg Brandl <georg@python.org>2007-08-15 14:27:07 (GMT)
commit739c01d47b9118d04e5722333f0e6b4d0c8bdd9e (patch)
treef82b450d291927fc1758b96d981aa0610947b529 /Doc/lib/caseless.py
parent2d1649094402ef393ea2b128ba2c08c3937e6b93 (diff)
downloadcpython-739c01d47b9118d04e5722333f0e6b4d0c8bdd9e.zip
cpython-739c01d47b9118d04e5722333f0e6b4d0c8bdd9e.tar.gz
cpython-739c01d47b9118d04e5722333f0e6b4d0c8bdd9e.tar.bz2
Delete the LaTeX doc tree.
Diffstat (limited to 'Doc/lib/caseless.py')
-rwxr-xr-xDoc/lib/caseless.py60
1 files changed, 0 insertions, 60 deletions
diff --git a/Doc/lib/caseless.py b/Doc/lib/caseless.py
deleted file mode 100755
index cae94be..0000000
--- a/Doc/lib/caseless.py
+++ /dev/null
@@ -1,60 +0,0 @@
-from optparse import Option, OptionParser, _match_abbrev
-
-# This case-insensitive option parser relies on having a
-# case-insensitive dictionary type available. Here's one
-# for Python 2.2. Note that a *real* case-insensitive
-# dictionary type would also have to implement __new__(),
-# update(), and setdefault() -- but that's not the point
-# of this exercise.
-
-class caseless_dict (dict):
- def __setitem__ (self, key, value):
- dict.__setitem__(self, key.lower(), value)
-
- def __getitem__ (self, key):
- return dict.__getitem__(self, key.lower())
-
- def get (self, key, default=None):
- return dict.get(self, key.lower())
-
- def has_key (self, key):
- return dict.has_key(self, key.lower())
-
-
-class CaselessOptionParser (OptionParser):
-
- def _create_option_list (self):
- self.option_list = []
- self._short_opt = caseless_dict()
- self._long_opt = caseless_dict()
- self._long_opts = []
- self.defaults = {}
-
- def _match_long_opt (self, opt):
- return _match_abbrev(opt.lower(), self._long_opt.keys())
-
-
-if __name__ == "__main__":
- from optik.errors import OptionConflictError
-
- # test 1: no options to start with
- parser = CaselessOptionParser()
- try:
- parser.add_option("-H", dest="blah")
- except OptionConflictError:
- print "ok: got OptionConflictError for -H"
- else:
- print "not ok: no conflict between -h and -H"
-
- parser.add_option("-f", "--file", dest="file")
- #print repr(parser.get_option("-f"))
- #print repr(parser.get_option("-F"))
- #print repr(parser.get_option("--file"))
- #print repr(parser.get_option("--fIlE"))
- (options, args) = parser.parse_args(["--FiLe", "foo"])
- assert options.file == "foo", options.file
- print "ok: case insensitive long options work"
-
- (options, args) = parser.parse_args(["-F", "bar"])
- assert options.file == "bar", options.file
- print "ok: case insensitive short options work"