-
Notifications
You must be signed in to change notification settings - Fork 932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import the part of PEP 566 about transforming core metadata to JSON #1466
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,6 @@ definition, the practical standard is set by what the standard library | |
Whenever metadata is serialised to a byte stream (for example, to save | ||
to a file), strings must be serialised using the UTF-8 encoding. | ||
|
||
Although :pep:`566` defined a way to transform metadata into a JSON-compatible | ||
dictionary, this is not yet used as a standard interchange format. The need for | ||
tools to work with years worth of existing packages makes it difficult to shift | ||
to a new format. | ||
|
||
.. note:: *Interpreting old metadata:* In :pep:`566`, the version specifier | ||
field format specification was relaxed to accept the syntax used by popular | ||
publishing tools (namely to remove the requirement that version specifiers | ||
|
@@ -848,6 +843,27 @@ Example:: | |
Obsoletes: Gorgon | ||
|
||
|
||
Transforming core metadata to JSON | ||
================================== | ||
|
||
It may be necessary to store metadata in a data structure which does not allow | ||
for multiple repeated keys, such as JSON. This specification defines a way to | ||
transform metadata into a JSON-compatible dictionary [#json-not-interchange]_. | ||
|
||
#. The original key-value format should be read with | ||
``email.parser.HeaderParser``. | ||
#. All transformed keys should be reduced to lower case. Hyphens should be | ||
replaced with underscores, but otherwise should retain all other characters. | ||
#. The transformed value for any field marked with "(multiple use)" should be a | ||
single list containing all the original values for the given key. | ||
#. The ``Keywords`` field should be converted to a list by splitting the | ||
original value on commas. | ||
#. The message body, if present, should be set to the value of the | ||
``description`` key. | ||
#. The result should be stored as a string-keyed dictionary. | ||
|
||
|
||
|
||
---- | ||
|
||
.. [1] reStructuredText markup: | ||
|
@@ -857,3 +873,7 @@ Example:: | |
|
||
.. [2] RFC 822 Long Header Fields: | ||
:rfc:`822#section-3.1.1` | ||
|
||
.. [#json-not-interchange] This is not yet used as a standard interchange | ||
format; the need for tools to work with years worth of existing packages | ||
makes it difficult to shift to a new format. | ||
Comment on lines
+877
to
+879
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this should be a warning note rather than a footnote. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply stating the process seems a little sudden. Perhaps add the introduction from the PEP: