2024-03-03 17:15:23 +00:00
|
|
|
# Copyright 2009-2024 Joshua Bronson. All rights reserved.
|
2021-05-08 14:25:29 +00:00
|
|
|
#
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
|
2024-03-03 17:15:23 +00:00
|
|
|
# ============================================================================
|
2021-05-08 14:25:29 +00:00
|
|
|
# * Welcome to the bidict source code *
|
2024-03-03 17:15:23 +00:00
|
|
|
# ============================================================================
|
2021-05-08 14:25:29 +00:00
|
|
|
|
2022-11-07 18:06:49 +00:00
|
|
|
# Reading through the code? You'll find a "Code review nav" comment like the one
|
|
|
|
# below at the top and bottom of the key source files. Follow these cues to take
|
|
|
|
# a path through the code that's optimized for familiarizing yourself with it.
|
2021-05-08 14:25:29 +00:00
|
|
|
#
|
2022-11-07 18:06:49 +00:00
|
|
|
# If you're not reading this on https://github.com/jab/bidict already, go there
|
|
|
|
# to ensure you have the latest version of the code. While there, you can also
|
|
|
|
# star the project, watch it for updates, fork the code, and submit an issue or
|
|
|
|
# pull request with any proposed changes. More information can be found linked
|
|
|
|
# from README.rst, which is also shown on https://github.com/jab/bidict.
|
2021-05-08 14:25:29 +00:00
|
|
|
|
|
|
|
# * Code review nav *
|
2024-03-03 17:15:23 +00:00
|
|
|
# ============================================================================
|
2022-11-07 18:06:49 +00:00
|
|
|
# Current: __init__.py Next: _abc.py →
|
2024-03-03 17:15:23 +00:00
|
|
|
# ============================================================================
|
2021-05-08 14:25:29 +00:00
|
|
|
|
|
|
|
|
2022-01-24 04:07:52 +00:00
|
|
|
"""The bidirectional mapping library for Python.
|
|
|
|
|
2022-11-07 18:06:49 +00:00
|
|
|
----
|
|
|
|
|
2022-01-24 04:07:52 +00:00
|
|
|
bidict by example:
|
2021-05-08 14:25:29 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
>>> from bidict import bidict
|
|
|
|
>>> element_by_symbol = bidict({'H': 'hydrogen'})
|
|
|
|
>>> element_by_symbol['H']
|
|
|
|
'hydrogen'
|
|
|
|
>>> element_by_symbol.inverse['hydrogen']
|
|
|
|
'H'
|
|
|
|
|
|
|
|
|
|
|
|
Please see https://github.com/jab/bidict for the most up-to-date code and
|
|
|
|
https://bidict.readthedocs.io for the most up-to-date documentation
|
|
|
|
if you are reading this elsewhere.
|
|
|
|
|
2022-11-07 18:06:49 +00:00
|
|
|
----
|
2021-05-08 14:25:29 +00:00
|
|
|
|
2024-03-03 17:15:23 +00:00
|
|
|
.. :copyright: (c) 2009-2024 Joshua Bronson.
|
2021-05-08 14:25:29 +00:00
|
|
|
.. :license: MPLv2. See LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
2022-01-24 04:07:52 +00:00
|
|
|
# Use private aliases to not re-export these publicly (for Sphinx automodule with imported-members).
|
2024-03-03 17:15:23 +00:00
|
|
|
from __future__ import annotations as _annotations
|
|
|
|
|
|
|
|
from contextlib import suppress as _suppress
|
|
|
|
|
|
|
|
from ._abc import BidirectionalMapping as BidirectionalMapping
|
|
|
|
from ._abc import MutableBidirectionalMapping as MutableBidirectionalMapping
|
|
|
|
from ._base import BidictBase as BidictBase
|
|
|
|
from ._base import BidictKeysView as BidictKeysView
|
|
|
|
from ._base import GeneratedBidictInverse as GeneratedBidictInverse
|
|
|
|
from ._bidict import MutableBidict as MutableBidict
|
|
|
|
from ._bidict import bidict as bidict
|
|
|
|
from ._dup import DROP_NEW as DROP_NEW
|
|
|
|
from ._dup import DROP_OLD as DROP_OLD
|
|
|
|
from ._dup import ON_DUP_DEFAULT as ON_DUP_DEFAULT
|
|
|
|
from ._dup import ON_DUP_DROP_OLD as ON_DUP_DROP_OLD
|
|
|
|
from ._dup import ON_DUP_RAISE as ON_DUP_RAISE
|
|
|
|
from ._dup import RAISE as RAISE
|
|
|
|
from ._dup import OnDup as OnDup
|
|
|
|
from ._dup import OnDupAction as OnDupAction
|
|
|
|
from ._exc import BidictException as BidictException
|
|
|
|
from ._exc import DuplicationError as DuplicationError
|
|
|
|
from ._exc import KeyAndValueDuplicationError as KeyAndValueDuplicationError
|
|
|
|
from ._exc import KeyDuplicationError as KeyDuplicationError
|
|
|
|
from ._exc import ValueDuplicationError as ValueDuplicationError
|
|
|
|
from ._frozen import frozenbidict as frozenbidict
|
|
|
|
from ._iter import inverted as inverted
|
2022-11-07 18:06:49 +00:00
|
|
|
from ._orderedbase import OrderedBidictBase as OrderedBidictBase
|
|
|
|
from ._orderedbidict import OrderedBidict as OrderedBidict
|
2024-03-03 17:15:23 +00:00
|
|
|
from .metadata import __author__ as __author__
|
|
|
|
from .metadata import __copyright__ as __copyright__
|
|
|
|
from .metadata import __description__ as __description__
|
|
|
|
from .metadata import __license__ as __license__
|
|
|
|
from .metadata import __url__ as __url__
|
|
|
|
from .metadata import __version__ as __version__
|
2022-11-07 18:06:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Set __module__ of re-exported classes to the 'bidict' top-level module, so that e.g.
|
|
|
|
# 'bidict.bidict' shows up as 'bidict.bidict` rather than 'bidict._bidict.bidict'.
|
|
|
|
for _obj in tuple(locals().values()): # pragma: no cover
|
2022-01-24 04:07:52 +00:00
|
|
|
if not getattr(_obj, '__module__', '').startswith('bidict.'):
|
|
|
|
continue
|
2024-03-03 17:15:23 +00:00
|
|
|
with _suppress(AttributeError):
|
2022-01-24 04:07:52 +00:00
|
|
|
_obj.__module__ = 'bidict'
|
|
|
|
|
2021-05-08 14:25:29 +00:00
|
|
|
|
|
|
|
# * Code review nav *
|
2024-03-03 17:15:23 +00:00
|
|
|
# ============================================================================
|
2022-11-07 18:06:49 +00:00
|
|
|
# Current: __init__.py Next: _abc.py →
|
2024-03-03 17:15:23 +00:00
|
|
|
# ============================================================================
|