Metadata-Version: 1.1
Name: abbrev
Version: 0.9.2
Summary: A dictionary that allows abbreviations
Home-page: https://github.com/rec/abbrev
Author: Tom Ritchford
Author-email: tom@swirly.com
License: MIT
Description: 🐜 abbrev: look up abbreviations in a dictionary 🐜
        
        Handy when the user has a choice of commands with long names.
        
        
        EXAMPLE
        =========
        
        .. code-block:: python
        
            import abbrev
            d = {'one': 1, 'two': 2, 'three': 3}
        
            assert abbrev(d, 'one') == 1
            assert abbrev(d, 'o') == 1
            assert abbrev(d, 'tw') == 2
        
            abbrev(d, 'four')  # Raises a KeyError: no such key
            abbrev(d, 't')  # Raises a KeyError: ambiguous
        
            # You can "curry" a specific dictionary, and save it to call:
            curry = abbrev(d)
        
            assert curry('one') == 1
            assert curry('tw') == 2
        
            # In multi mode, you get all the results:
            multi = abbrev(d, multi=True)
            assert multi('t') == abbrev(d, 't', multi=True) == ('two', 'three')
            assert multi('o') == abbrev(d, 'o', multi=True) == ('one', )
            multi('four')  # Still raises a key error
        
            # Turn off unique, and you get the first result:
            assert abbrev(d, 't', unique=False) == ('two',)
        
        API
        ---
        
        ``abbrev()``
        ~~~~~~~~~~~~
        
        .. code-block:: python
        
          abbrev(
               abbrevs,
               key=NONE,
               default=NONE,
               multi=False,
               unique=True,
          )
        
        (`abbrev.py, 47-103 <https://github.com/rec/abbrev/blob/master/abbrev.py#L47-L103>`_)
        
        Look up abbreviations in a dictionary.  Handy when the user
        has a choice of commands with long names.
        
        ARGUMENTS
          abbrevs:
            A dictionary with string keys
        
          key:
            An abbreviated key to look up in ``abbrevs``,
        
            If ``key`` is omitted, ``abbrev`` returns a callable that looks up
            abbreviations in ``abbrevs``
        
          default:
            if ``key`` is not found in the dictionary, ``default`` is returned, if it's
            set.  Otherwise, missing keys throw a KeyError
        
          multi:
            If True, a tuple of matching keys is returned on a match
            If False, the default, only a single matching value is returned
        
          unique:
            If True, the default, ``abbrev`` raises a KeyError if more than one key
            matches.  If False, ``abbrev`` returns the first match.
        
            ``unique`` is ignored if ``multi`` is set
        
        (automatically generated by `doks <https://github.com/rec/doks/>`_ on 2021-03-27T15:52:29.716734)
        
Keywords: testing,modules
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
