Logo Search packages:      
Sourcecode: jhbuild version File versions  Download package

def jhbuild::cut_n_paste::optparse::_match_abbrev (   s,
  wordmap 
) [private]

_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.

Definition at line 1643 of file optparse.py.

01643                              :
    """_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 wordmap.has_key(s):
        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.
            raise AmbiguousOptionError(s, possibilities)


# Some day, there might be many Option classes.  As of Optik 1.3, the
# preferred way to instantiate Options is indirectly, via make_option(),
# which will become a factory function when there are many Option
# classes.
make_option = Option


Generated by  Doxygen 1.6.0   Back to index