Aluode/PerceptionLabPortable
0
1Metadata-Version: 2.42Name: idna3Version: 3.114Summary: Internationalized Domain Names in Applications (IDNA)5Author-email: Kim Davies <kim+pypi@gumleaf.org>6Requires-Python: >=3.87Description-Content-Type: text/x-rst8License-Expression: BSD-3-Clause9Classifier: Development Status :: 5 - Production/Stable10Classifier: Intended Audience :: Developers11Classifier: Intended Audience :: System Administrators12Classifier: Operating System :: OS Independent13Classifier: Programming Language :: Python14Classifier: Programming Language :: Python :: 315Classifier: Programming Language :: Python :: 3 :: Only16Classifier: Programming Language :: Python :: 3.817Classifier: Programming Language :: Python :: 3.918Classifier: Programming Language :: Python :: 3.1019Classifier: Programming Language :: Python :: 3.1120Classifier: Programming Language :: Python :: 3.1221Classifier: Programming Language :: Python :: 3.1322Classifier: Programming Language :: Python :: 3.1423Classifier: Programming Language :: Python :: Implementation :: CPython24Classifier: Programming Language :: Python :: Implementation :: PyPy25Classifier: Topic :: Internet :: Name Service (DNS)26Classifier: Topic :: Software Development :: Libraries :: Python Modules27Classifier: Topic :: Utilities28License-File: LICENSE.md29Requires-Dist: ruff >= 0.6.2 ; extra == "all"30Requires-Dist: mypy >= 1.11.2 ; extra == "all"31Requires-Dist: pytest >= 8.3.2 ; extra == "all"32Requires-Dist: flake8 >= 7.1.1 ; extra == "all"33Project-URL: Changelog, https://github.com/kjd/idna/blob/master/HISTORY.rst34Project-URL: Issue tracker, https://github.com/kjd/idna/issues35Project-URL: Source, https://github.com/kjd/idna36Provides-Extra: all37 38Internationalized Domain Names in Applications (IDNA)39=====================================================40 41Support for `Internationalized Domain Names in42Applications (IDNA) <https://tools.ietf.org/html/rfc5891>`_43and `Unicode IDNA Compatibility Processing44<https://unicode.org/reports/tr46/>`_.45 46The latest versions of these standards supplied here provide47more comprehensive language coverage and reduce the potential of48allowing domains with known security vulnerabilities. This library49is a suitable replacement for the “encodings.idna”50module that comes with the Python standard library, but which51only supports an older superseded IDNA specification from 2003.52 53Basic functions are simply executed:54 55.. code-block:: pycon56 57 >>> import idna58 >>> idna.encode('ドメイン.テスト')59 b'xn--eckwd4c7c.xn--zckzah'60 >>> print(idna.decode('xn--eckwd4c7c.xn--zckzah'))61 ドメイン.テスト62 63 64Installation65------------66 67This package is available for installation from PyPI via the68typical mechanisms, such as:69 70.. code-block:: bash71 72 $ python3 -m pip install idna73 74 75Usage76-----77 78For typical usage, the ``encode`` and ``decode`` functions will take a79domain name argument and perform a conversion to ASCII compatible encoding80(known as A-labels), or to Unicode strings (known as U-labels)81respectively.82 83.. code-block:: pycon84 85 >>> import idna86 >>> idna.encode('ドメイン.テスト')87 b'xn--eckwd4c7c.xn--zckzah'88 >>> print(idna.decode('xn--eckwd4c7c.xn--zckzah'))89 ドメイン.テスト90 91Conversions can be applied at a per-label basis using the ``ulabel`` or92``alabel`` functions if necessary:93 94.. code-block:: pycon95 96 >>> idna.alabel('测试')97 b'xn--0zwm56d'98 99 100Compatibility Mapping (UTS #46)101+++++++++++++++++++++++++++++++102 103This library provides support for `Unicode IDNA Compatibility104Processing <https://unicode.org/reports/tr46/>`_ which normalizes input from105different potential ways a user may input a domain prior to performing the IDNA106conversion operations. This functionality, known as a 107`mapping <https://tools.ietf.org/html/rfc5895>`_, is considered by the108specification to be a local user-interface issue distinct from IDNA109conversion functionality.110 111For example, “Königsgäßchen” is not a permissible label as *LATIN112CAPITAL LETTER K* is not allowed (nor are capital letters in general).113UTS 46 will convert this into lower case prior to applying the IDNA114conversion.115 116.. code-block:: pycon117 118 >>> import idna119 >>> idna.encode('Königsgäßchen')120 ...121 idna.core.InvalidCodepoint: Codepoint U+004B at position 1 of 'Königsgäßchen' not allowed122 >>> idna.encode('Königsgäßchen', uts46=True)123 b'xn--knigsgchen-b4a3dun'124 >>> print(idna.decode('xn--knigsgchen-b4a3dun'))125 königsgäßchen126 127 128Exceptions129----------130 131All errors raised during the conversion following the specification132should raise an exception derived from the ``idna.IDNAError`` base133class.134 135More specific exceptions that may be generated as ``idna.IDNABidiError``136when the error reflects an illegal combination of left-to-right and137right-to-left characters in a label; ``idna.InvalidCodepoint`` when138a specific codepoint is an illegal character in an IDN label (i.e.139INVALID); and ``idna.InvalidCodepointContext`` when the codepoint is140illegal based on its position in the string (i.e. it is CONTEXTO or CONTEXTJ141but the contextual requirements are not satisfied.)142 143Building and Diagnostics144------------------------145 146The IDNA and UTS 46 functionality relies upon pre-calculated lookup147tables for performance. These tables are derived from computing against148eligibility criteria in the respective standards using the command-line149script ``tools/idna-data``.150 151This tool will fetch relevant codepoint data from the Unicode repository152and perform the required calculations to identify eligibility. There are153three main modes:154 155* ``idna-data make-libdata``. Generates ``idnadata.py`` and156 ``uts46data.py``, the pre-calculated lookup tables used for IDNA and157 UTS 46 conversions. Implementers who wish to track this library against158 a different Unicode version may use this tool to manually generate a159 different version of the ``idnadata.py`` and ``uts46data.py`` files.160 161* ``idna-data make-table``. Generate a table of the IDNA disposition162 (e.g. PVALID, CONTEXTJ, CONTEXTO) in the format found in Appendix163 B.1 of RFC 5892 and the pre-computed tables published by `IANA164 <https://www.iana.org/>`_.165 166* ``idna-data U+0061``. Prints debugging output on the various167 properties associated with an individual Unicode codepoint (in this168 case, U+0061), that are used to assess the IDNA and UTS 46 status of a169 codepoint. This is helpful in debugging or analysis.170 171The tool accepts a number of arguments, described using ``idna-data172-h``. Most notably, the ``--version`` argument allows the specification173of the version of Unicode to be used in computing the table data. For174example, ``idna-data --version 9.0.0 make-libdata`` will generate175library data against Unicode 9.0.0.176 177 178Additional Notes179----------------180 181* **Packages**. The latest tagged release version is published in the182 `Python Package Index <https://pypi.org/project/idna/>`_.183 184* **Version support**. This library supports Python 3.8 and higher.185 As this library serves as a low-level toolkit for a variety of186 applications, many of which strive for broad compatibility with older187 Python versions, there is no rush to remove older interpreter support.188 Support for older versions are likely to be removed from new releases189 as automated tests can no longer easily be run, i.e. once the Python190 version is officially end-of-life.191 192* **Testing**. The library has a test suite based on each rule of the193 IDNA specification, as well as tests that are provided as part of the194 Unicode Technical Standard 46, `Unicode IDNA Compatibility Processing195 <https://unicode.org/reports/tr46/>`_.196 197* **Emoji**. It is an occasional request to support emoji domains in198 this library. Encoding of symbols like emoji is expressly prohibited by199 the technical standard IDNA 2008 and emoji domains are broadly phased200 out across the domain industry due to associated security risks. For201 now, applications that need to support these non-compliant labels202 may wish to consider trying the encode/decode operation in this library203 first, and then falling back to using `encodings.idna`. See `the Github204 project <https://github.com/kjd/idna/issues/18>`_ for more discussion.205 206* **Transitional processing**. Unicode 16.0.0 removed transitional207 processing so the `transitional` argument for the encode() method208 no longer has any effect and will be removed at a later date.209 210 