METADATA 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. Metadata-Version: 2.1
  2. Name: idna
  3. Version: 2.10
  4. Summary: Internationalized Domain Names in Applications (IDNA)
  5. Home-page: https://github.com/kjd/idna
  6. Author: Kim Davies
  7. Author-email: kim@cynosure.com.au
  8. License: BSD-like
  9. Platform: UNKNOWN
  10. Classifier: Development Status :: 5 - Production/Stable
  11. Classifier: Intended Audience :: Developers
  12. Classifier: Intended Audience :: System Administrators
  13. Classifier: License :: OSI Approved :: BSD License
  14. Classifier: Operating System :: OS Independent
  15. Classifier: Programming Language :: Python
  16. Classifier: Programming Language :: Python :: 2
  17. Classifier: Programming Language :: Python :: 2.7
  18. Classifier: Programming Language :: Python :: 3
  19. Classifier: Programming Language :: Python :: 3.4
  20. Classifier: Programming Language :: Python :: 3.5
  21. Classifier: Programming Language :: Python :: 3.6
  22. Classifier: Programming Language :: Python :: 3.7
  23. Classifier: Programming Language :: Python :: 3.8
  24. Classifier: Programming Language :: Python :: Implementation :: CPython
  25. Classifier: Programming Language :: Python :: Implementation :: PyPy
  26. Classifier: Topic :: Internet :: Name Service (DNS)
  27. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  28. Classifier: Topic :: Utilities
  29. Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  30. Internationalized Domain Names in Applications (IDNA)
  31. =====================================================
  32. Support for the Internationalised Domain Names in Applications
  33. (IDNA) protocol as specified in `RFC 5891 <http://tools.ietf.org/html/rfc5891>`_.
  34. This is the latest version of the protocol and is sometimes referred to as
  35. “IDNA 2008”.
  36. This library also provides support for Unicode Technical Standard 46,
  37. `Unicode IDNA Compatibility Processing <http://unicode.org/reports/tr46/>`_.
  38. This acts as a suitable replacement for the “encodings.idna” module that
  39. comes with the Python standard library, but only supports the
  40. old, deprecated IDNA specification (`RFC 3490 <http://tools.ietf.org/html/rfc3490>`_).
  41. Basic functions are simply executed:
  42. .. code-block:: pycon
  43. # Python 3
  44. >>> import idna
  45. >>> idna.encode('ドメイン.テスト')
  46. b'xn--eckwd4c7c.xn--zckzah'
  47. >>> print(idna.decode('xn--eckwd4c7c.xn--zckzah'))
  48. ドメイン.テスト
  49. # Python 2
  50. >>> import idna
  51. >>> idna.encode(u'ドメイン.テスト')
  52. 'xn--eckwd4c7c.xn--zckzah'
  53. >>> print idna.decode('xn--eckwd4c7c.xn--zckzah')
  54. ドメイン.テスト
  55. Packages
  56. --------
  57. The latest tagged release version is published in the PyPI repository:
  58. .. image:: https://badge.fury.io/py/idna.svg
  59. :target: http://badge.fury.io/py/idna
  60. Installation
  61. ------------
  62. To install this library, you can use pip:
  63. .. code-block:: bash
  64. $ pip install idna
  65. Alternatively, you can install the package using the bundled setup script:
  66. .. code-block:: bash
  67. $ python setup.py install
  68. This library works with Python 2.7 and Python 3.4 or later.
  69. Usage
  70. -----
  71. For typical usage, the ``encode`` and ``decode`` functions will take a domain
  72. name argument and perform a conversion to A-labels or U-labels respectively.
  73. .. code-block:: pycon
  74. # Python 3
  75. >>> import idna
  76. >>> idna.encode('ドメイン.テスト')
  77. b'xn--eckwd4c7c.xn--zckzah'
  78. >>> print(idna.decode('xn--eckwd4c7c.xn--zckzah'))
  79. ドメイン.テスト
  80. You may use the codec encoding and decoding methods using the
  81. ``idna.codec`` module:
  82. .. code-block:: pycon
  83. # Python 2
  84. >>> import idna.codec
  85. >>> print u'домена.испытание'.encode('idna')
  86. xn--80ahd1agd.xn--80akhbyknj4f
  87. >>> print 'xn--80ahd1agd.xn--80akhbyknj4f'.decode('idna')
  88. домена.испытание
  89. Conversions can be applied at a per-label basis using the ``ulabel`` or ``alabel``
  90. functions if necessary:
  91. .. code-block:: pycon
  92. # Python 2
  93. >>> idna.alabel(u'测试')
  94. 'xn--0zwm56d'
  95. Compatibility Mapping (UTS #46)
  96. +++++++++++++++++++++++++++++++
  97. As described in `RFC 5895 <http://tools.ietf.org/html/rfc5895>`_, the IDNA
  98. specification no longer normalizes input from different potential ways a user
  99. may input a domain name. This functionality, known as a “mapping”, is now
  100. considered by the specification to be a local user-interface issue distinct
  101. from IDNA conversion functionality.
  102. This library provides one such mapping, that was developed by the Unicode
  103. Consortium. Known as `Unicode IDNA Compatibility Processing <http://unicode.org/reports/tr46/>`_,
  104. it provides for both a regular mapping for typical applications, as well as
  105. a transitional mapping to help migrate from older IDNA 2003 applications.
  106. For example, “Königsgäßchen” is not a permissible label as *LATIN CAPITAL
  107. LETTER K* is not allowed (nor are capital letters in general). UTS 46 will
  108. convert this into lower case prior to applying the IDNA conversion.
  109. .. code-block:: pycon
  110. # Python 3
  111. >>> import idna
  112. >>> idna.encode(u'Königsgäßchen')
  113. ...
  114. idna.core.InvalidCodepoint: Codepoint U+004B at position 1 of 'Königsgäßchen' not allowed
  115. >>> idna.encode('Königsgäßchen', uts46=True)
  116. b'xn--knigsgchen-b4a3dun'
  117. >>> print(idna.decode('xn--knigsgchen-b4a3dun'))
  118. königsgäßchen
  119. Transitional processing provides conversions to help transition from the older
  120. 2003 standard to the current standard. For example, in the original IDNA
  121. specification, the *LATIN SMALL LETTER SHARP S* (ß) was converted into two
  122. *LATIN SMALL LETTER S* (ss), whereas in the current IDNA specification this
  123. conversion is not performed.
  124. .. code-block:: pycon
  125. # Python 2
  126. >>> idna.encode(u'Königsgäßchen', uts46=True, transitional=True)
  127. 'xn--knigsgsschen-lcb0w'
  128. Implementors should use transitional processing with caution, only in rare
  129. cases where conversion from legacy labels to current labels must be performed
  130. (i.e. IDNA implementations that pre-date 2008). For typical applications
  131. that just need to convert labels, transitional processing is unlikely to be
  132. beneficial and could produce unexpected incompatible results.
  133. ``encodings.idna`` Compatibility
  134. ++++++++++++++++++++++++++++++++
  135. Function calls from the Python built-in ``encodings.idna`` module are
  136. mapped to their IDNA 2008 equivalents using the ``idna.compat`` module.
  137. Simply substitute the ``import`` clause in your code to refer to the
  138. new module name.
  139. Exceptions
  140. ----------
  141. All errors raised during the conversion following the specification should
  142. raise an exception derived from the ``idna.IDNAError`` base class.
  143. More specific exceptions that may be generated as ``idna.IDNABidiError``
  144. when the error reflects an illegal combination of left-to-right and right-to-left
  145. characters in a label; ``idna.InvalidCodepoint`` when a specific codepoint is
  146. an illegal character in an IDN label (i.e. INVALID); and ``idna.InvalidCodepointContext``
  147. when the codepoint is illegal based on its positional context (i.e. it is CONTEXTO
  148. or CONTEXTJ but the contextual requirements are not satisfied.)
  149. Building and Diagnostics
  150. ------------------------
  151. The IDNA and UTS 46 functionality relies upon pre-calculated lookup tables for
  152. performance. These tables are derived from computing against eligibility criteria
  153. in the respective standards. These tables are computed using the command-line
  154. script ``tools/idna-data``.
  155. This tool will fetch relevant tables from the Unicode Consortium and perform the
  156. required calculations to identify eligibility. It has three main modes:
  157. * ``idna-data make-libdata``. Generates ``idnadata.py`` and ``uts46data.py``,
  158. the pre-calculated lookup tables using for IDNA and UTS 46 conversions. Implementors
  159. who wish to track this library against a different Unicode version may use this tool
  160. to manually generate a different version of the ``idnadata.py`` and ``uts46data.py``
  161. files.
  162. * ``idna-data make-table``. Generate a table of the IDNA disposition
  163. (e.g. PVALID, CONTEXTJ, CONTEXTO) in the format found in Appendix B.1 of RFC
  164. 5892 and the pre-computed tables published by `IANA <http://iana.org/>`_.
  165. * ``idna-data U+0061``. Prints debugging output on the various properties
  166. associated with an individual Unicode codepoint (in this case, U+0061), that are
  167. used to assess the IDNA and UTS 46 status of a codepoint. This is helpful in debugging
  168. or analysis.
  169. The tool accepts a number of arguments, described using ``idna-data -h``. Most notably,
  170. the ``--version`` argument allows the specification of the version of Unicode to use
  171. in computing the table data. For example, ``idna-data --version 9.0.0 make-libdata``
  172. will generate library data against Unicode 9.0.0.
  173. Note that this script requires Python 3, but all generated library data will work
  174. in Python 2.7.
  175. Testing
  176. -------
  177. The library has a test suite based on each rule of the IDNA specification, as
  178. well as tests that are provided as part of the Unicode Technical Standard 46,
  179. `Unicode IDNA Compatibility Processing <http://unicode.org/reports/tr46/>`_.
  180. The tests are run automatically on each commit at Travis CI:
  181. .. image:: https://travis-ci.org/kjd/idna.svg?branch=master
  182. :target: https://travis-ci.org/kjd/idna