All Samples(94) | Call(47) | Derive(0) | Import(47)
_match_abbrev(s : string, wordmap : {string : Option}) -> string
Return the string key in 'wordmap' for which 's' is an unambiguous
abbreviation. If 's' is found to be ambiguous or doesn't match any of
'words', raise BadOptionError.
def _match_abbrev(s, wordmap):
"""_match_abbrev(s : string, wordmap : {string : Option}) -> string
Return the string key in 'wordmap' for which 's' is an unambiguous
abbreviation. If 's' is found to be ambiguous or doesn't match any of
'words', raise BadOptionError.
"""
# Is there an exact match?
if s in wordmap:
return s
else:
# Isolate all words with s as a prefix.
possibilities = [word for word in wordmap.keys()
if word.startswith(s)]
# No exact match, so there had better be just one possibility.
if len(possibilities) == 1:
return possibilities[0]
elif not possibilities:
raise BadOptionError(s)
else:
# More than one possible completion: ambiguous prefix.
possibilities.sort()
raise AmbiguousOptionError(s, possibilities)
import os, sys
from copy import copy
from optparse import Option, OptionValueError, OptionParser, OptionGroup, _match_abbrev, BadOptionError
from AlbumBase import VERSION, EXCLUDEDIRS, CONFIGFILE, OUTPUTDIR, \
TEMPLATEFILENAME, OPTSOURCES, DEFEXTPICTURE, DEFEXTMOVIE, DEFEXTSOUND
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt)
# ======================================================
# extend optparse.OptionParser with new type 'bool'
src/s/p/spike-HEAD/vendor/stackless/v2.5.1/Doc/lib/caseless.py spike(Download)
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
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt.keys())
if __name__ == "__main__":
from optik.errors import OptionConflictError
src/s/p/spike-HEAD/vendor/stackless/current/Doc/lib/caseless.py spike(Download)
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
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt.keys())
if __name__ == "__main__":
from optik.errors import OptionConflictError
src/s/p/spike-HEAD/vendor/Python/v2.5.1/Doc/lib/caseless.py spike(Download)
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
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt.keys())
if __name__ == "__main__":
from optik.errors import OptionConflictError
src/s/p/spike-HEAD/vendor/Python/current/Doc/lib/caseless.py spike(Download)
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
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt.keys())
if __name__ == "__main__":
from optik.errors import OptionConflictError
src/p/y/pyalbum-HEAD/pyalbum/AlbumOptions.py pyalbum(Download)
import os, sys
from copy import copy
from optparse import Option, OptionValueError, OptionParser, OptionGroup, _match_abbrev, BadOptionError
from AlbumBase import VERSION, EXCLUDEDIRS, CONFIGFILE, OUTPUTDIR, \
TEMPLATEFILENAME, OPTSOURCES, DEFEXTPICTURE, DEFEXTMOVIE, DEFEXTSOUND
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt)
# ======================================================
# extend optparse.OptionParser with new type 'bool'
src/u/n/unixpiger-HEAD/trunk/monitor/api/python/Doc/lib/caseless.py unixpiger(Download)
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
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt.keys())
if __name__ == "__main__":
from optik.errors import OptionConflictError
src/u/n/unixpiger-HEAD/monitor/api/python/Doc/lib/caseless.py unixpiger(Download)
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
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt.keys())
if __name__ == "__main__":
from optik.errors import OptionConflictError
src/p/y/pythonwine-HEAD/Doc/lib/caseless.py pythonwine(Download)
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
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt.keys())
if __name__ == "__main__":
from optik.errors import OptionConflictError
src/x/b/xbmc-HEAD/xbmc/lib/libPython/Python/Doc/lib/caseless.py xbmc(Download)
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
def _match_long_opt (self, opt):
return _match_abbrev(opt.lower(), self._long_opt.keys())
if __name__ == "__main__":
from optik.errors import OptionConflictError
1 | 2 | 3 | 4 | 5 Next