METADATA 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. Metadata-Version: 2.1
  2. Name: configparser
  3. Version: 3.7.4
  4. Summary: Updated configparser from Python 3.7 for Python 2.6+.
  5. Home-page: https://github.com/jaraco/configparser/
  6. Author: Łukasz Langa
  7. Author-email: lukasz@langa.pl
  8. Maintainer: Jason R. Coombs
  9. Maintainer-email: jaraco@jaraco.com
  10. License: UNKNOWN
  11. Keywords: configparser ini parsing conf cfg configuration file
  12. Platform: any
  13. Classifier: Development Status :: 5 - Production/Stable
  14. Classifier: Intended Audience :: Developers
  15. Classifier: License :: OSI Approved :: MIT License
  16. Classifier: Programming Language :: Python :: 2.7
  17. Classifier: Programming Language :: Python :: 3
  18. Requires-Python: >=2.6
  19. Provides-Extra: docs
  20. Requires-Dist: sphinx ; extra == 'docs'
  21. Requires-Dist: jaraco.packaging (>=3.2) ; extra == 'docs'
  22. Requires-Dist: rst.linker (>=1.9) ; extra == 'docs'
  23. Provides-Extra: testing
  24. Requires-Dist: pytest (!=3.7.3,>=3.5) ; extra == 'testing'
  25. Requires-Dist: pytest-checkdocs (>=1.2) ; extra == 'testing'
  26. Requires-Dist: pytest-flake8 ; extra == 'testing'
  27. .. image:: https://img.shields.io/pypi/v/configparser.svg
  28. :target: https://pypi.org/project/configparser
  29. .. image:: https://img.shields.io/pypi/pyversions/configparser.svg
  30. .. image:: https://img.shields.io/travis/jaraco/configparser/master.svg
  31. :target: https://travis-ci.org/jaraco/configparser
  32. .. .. image:: https://img.shields.io/appveyor/ci/jaraco/configparser/master.svg
  33. .. :target: https://ci.appveyor.com/project/jaraco/configparser/branch/master
  34. .. image:: https://readthedocs.org/projects/configparser/badge/?version=latest
  35. :target: https://configparser.readthedocs.io/en/latest/?badge=latest
  36. .. image:: https://tidelift.com/badges/github/jaraco/configparser
  37. :target: https://tidelift.com/subscription/pkg/pypi-configparser?utm_source=pypi-configparser&utm_medium=readme
  38. The ancient ``ConfigParser`` module available in the standard library 2.x has
  39. seen a major update in Python 3.2. This is a backport of those changes so that
  40. they can be used directly in Python 2.6 - 3.5.
  41. To use the ``configparser`` backport instead of the built-in version on both
  42. Python 2 and Python 3, simply import it explicitly as a backport::
  43. from backports import configparser
  44. If you'd like to use the backport on Python 2 and the built-in version on
  45. Python 3, use that invocation instead::
  46. import configparser
  47. For detailed documentation consult the vanilla version at
  48. http://docs.python.org/3/library/configparser.html.
  49. Why you'll love ``configparser``
  50. --------------------------------
  51. Whereas almost completely compatible with its older brother, ``configparser``
  52. sports a bunch of interesting new features:
  53. * full mapping protocol access (`more info
  54. <http://docs.python.org/3/library/configparser.html#mapping-protocol-access>`_)::
  55. >>> parser = ConfigParser()
  56. >>> parser.read_string("""
  57. [DEFAULT]
  58. location = upper left
  59. visible = yes
  60. editable = no
  61. color = blue
  62. [main]
  63. title = Main Menu
  64. color = green
  65. [options]
  66. title = Options
  67. """)
  68. >>> parser['main']['color']
  69. 'green'
  70. >>> parser['main']['editable']
  71. 'no'
  72. >>> section = parser['options']
  73. >>> section['title']
  74. 'Options'
  75. >>> section['title'] = 'Options (editable: %(editable)s)'
  76. >>> section['title']
  77. 'Options (editable: no)'
  78. * there's now one default ``ConfigParser`` class, which basically is the old
  79. ``SafeConfigParser`` with a bunch of tweaks which make it more predictable for
  80. users. Don't need interpolation? Simply use
  81. ``ConfigParser(interpolation=None)``, no need to use a distinct
  82. ``RawConfigParser`` anymore.
  83. * the parser is highly `customizable upon instantiation
  84. <http://docs.python.org/3/library/configparser.html#customizing-parser-behaviour>`__
  85. supporting things like changing option delimiters, comment characters, the
  86. name of the DEFAULT section, the interpolation syntax, etc.
  87. * you can easily create your own interpolation syntax but there are two powerful
  88. implementations built-in (`more info
  89. <http://docs.python.org/3/library/configparser.html#interpolation-of-values>`__):
  90. * the classic ``%(string-like)s`` syntax (called ``BasicInterpolation``)
  91. * a new ``${buildout:like}`` syntax (called ``ExtendedInterpolation``)
  92. * fallback values may be specified in getters (`more info
  93. <http://docs.python.org/3/library/configparser.html#fallback-values>`__)::
  94. >>> config.get('closet', 'monster',
  95. ... fallback='No such things as monsters')
  96. 'No such things as monsters'
  97. * ``ConfigParser`` objects can now read data directly `from strings
  98. <http://docs.python.org/3/library/configparser.html#configparser.ConfigParser.read_string>`__
  99. and `from dictionaries
  100. <http://docs.python.org/3/library/configparser.html#configparser.ConfigParser.read_dict>`__.
  101. That means importing configuration from JSON or specifying default values for
  102. the whole configuration (multiple sections) is now a single line of code. Same
  103. goes for copying data from another ``ConfigParser`` instance, thanks to its
  104. mapping protocol support.
  105. * many smaller tweaks, updates and fixes
  106. A few words about Unicode
  107. -------------------------
  108. ``configparser`` comes from Python 3 and as such it works well with Unicode.
  109. The library is generally cleaned up in terms of internal data storage and
  110. reading/writing files. There are a couple of incompatibilities with the old
  111. ``ConfigParser`` due to that. However, the work required to migrate is well
  112. worth it as it shows the issues that would likely come up during migration of
  113. your project to Python 3.
  114. The design assumes that Unicode strings are used whenever possible [1]_. That
  115. gives you the certainty that what's stored in a configuration object is text.
  116. Once your configuration is read, the rest of your application doesn't have to
  117. deal with encoding issues. All you have is text [2]_. The only two phases when
  118. you should explicitly state encoding is when you either read from an external
  119. source (e.g. a file) or write back.
  120. Versioning
  121. ----------
  122. This backport is intended to keep 100% compatibility with the vanilla release in
  123. Python 3.2+. To help maintaining a version you want and expect, a versioning
  124. scheme is used where:
  125. * the first two numbers indicate the version of Python 3 from which the
  126. backport is done
  127. * a backport release number is provided as the final number (zero-indexed)
  128. For example, ``3.5.2`` is the **third** backport release of the
  129. ``configparser`` library as seen in Python 3.5. Note that ``3.5.2`` does
  130. **NOT** necessarily mean this backport version is based on the standard library
  131. of Python 3.5.2.
  132. One exception from the 100% compatibility principle is that bugs fixed before
  133. releasing another minor Python 3 bugfix version **will be included** in the
  134. backport releases done in the mean time.
  135. Maintenance
  136. -----------
  137. This backport was originally authored by Łukasz Langa, the current vanilla
  138. ``configparser`` maintainer for CPython and is currently maintained by
  139. Jason R. Coombs:
  140. * `configparser repository <https://github.com/jaraco/configparser>`_
  141. * `configparser issue tracker <https://github.com/jaraco/configparser/issues>`_
  142. Security Contact
  143. ----------------
  144. To report a security vulnerability, please use the
  145. `Tidelift security contact <https://tidelift.com/security>`_.
  146. Tidelift will coordinate the fix and disclosure.
  147. Conversion Process
  148. ------------------
  149. This section is technical and should bother you only if you are wondering how
  150. this backport is produced. If the implementation details of this backport are
  151. not important for you, feel free to ignore the following content.
  152. ``configparser`` is converted using `python-future
  153. <http://python-future.org>`_ and free time. Because a fully automatic
  154. conversion was not doable, I took the following branching approach:
  155. * the ``3.x`` branch holds unchanged files synchronized from the upstream
  156. CPython repository. The synchronization is currently done by manually copying
  157. the required files and stating from which CPython changeset they come from.
  158. * the ``master`` branch holds a version of the ``3.x`` code with some tweaks
  159. that make it independent from libraries and constructions unavailable on 2.x.
  160. Code on this branch still *must* work on the corresponding Python 3.x but
  161. will also work on Python 2.6 and 2.7 (including PyPy). You can check this
  162. running the supplied unit tests with ``tox``.
  163. The process works like this:
  164. 1. In the ``3.x`` branch, run ``pip-run -- sync-upstream.py``, which
  165. downloads the latest stable release of Python and copies the relevant
  166. files from there into their new locations here and then commits those
  167. changes with a nice reference to the relevant upstream commit hash.
  168. 2. I check for new names in ``__all__`` and update imports in
  169. ``configparser.py`` accordingly. I run the tests on Python 3. Commit.
  170. 3. I merge the new commit to ``master``. I run ``tox``. Commit.
  171. 4. If there are necessary changes, I do them now (on ``master``). Note that
  172. the changes should be written in the syntax subset supported by Python
  173. 2.6.
  174. 5. I run ``tox``. If it works, I update the docs and release the new version.
  175. Otherwise, I go back to point 3. I might use ``pasteurize`` to suggest me
  176. required changes but usually I do them manually to keep resulting code in
  177. a nicer form.
  178. Footnotes
  179. ---------
  180. .. [1] To somewhat ease migration, passing bytestrings is still supported but
  181. they are converted to Unicode for internal storage anyway. This means
  182. that for the vast majority of strings used in configuration files, it
  183. won't matter if you pass them as bytestrings or Unicode. However, if you
  184. pass a bytestring that cannot be converted to Unicode using the naive
  185. ASCII codec, a ``UnicodeDecodeError`` will be raised. This is purposeful
  186. and helps you manage proper encoding for all content you store in
  187. memory, read from various sources and write back.
  188. .. [2] Life gets much easier when you understand that you basically manage
  189. **text** in your application. You don't care about bytes but about
  190. letters. In that regard the concept of content encoding is meaningless.
  191. The only time when you deal with raw bytes is when you write the data to
  192. a file. Then you have to specify how your text should be encoded. On
  193. the other end, to get meaningful text from a file, the application
  194. reading it has to know which encoding was used during its creation. But
  195. once the bytes are read and properly decoded, all you have is text. This
  196. is especially powerful when you start interacting with multiple data
  197. sources. Even if each of them uses a different encoding, inside your
  198. application data is held in abstract text form. You can program your
  199. business logic without worrying about which data came from which source.
  200. You can freely exchange the data you store between sources. Only
  201. reading/writing files requires encoding your text to bytes.