Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ab7341d
bpo-36673: Implement comment/PI parsing support for the TreeBuilder i…
scoder Apr 20, 2019
2d2df11
bpo-36673: Rewrite the comment/PI factory handling for the TreeBuilde…
scoder Apr 20, 2019
aa52e04
bpo-36676: Implement namespace prefix aware parsing support for the X…
scoder Apr 20, 2019
3b33264
bpo-36676: Add test to see if a target only with an "end_ns()" callba…
scoder Apr 22, 2019
7f0ed48
Implement C14N 2.0 as a new canonicalize() function in ElementTree.
scoder Apr 26, 2019
c00dd43
Add news entry
scoder Apr 26, 2019
08f1137
Correct input file handling in test: must not decode it on the way in…
scoder Apr 26, 2019
5d96e2f
Slightly faster attribute serialisation.
scoder Apr 26, 2019
35f2e81
Reduce overhead for the common cases of no new namespace declarations…
scoder Apr 26, 2019
36ea639
Rename C14N 'comments' option to 'with_comments' to clarify its purpo…
scoder Apr 27, 2019
8bb48f1
Implement C14N exclusion of specific elements and attributes.
scoder Apr 28, 2019
dad95e8
Extend exclusion tests to cover the whitespace left-overs of excluded…
scoder Apr 29, 2019
45f742b
Add documentation.
scoder Apr 29, 2019
037b644
Make the canonicalize() function more versatile by letting it return …
scoder Apr 29, 2019
3acd010
Fix docstring.
scoder Apr 29, 2019
e0500e8
Support (and test) canonicalizing from a file path in addition to onl…
scoder Apr 29, 2019
a94b07d
Update documentation now that canonicalize() supports file paths as i…
scoder Apr 29, 2019
93e2c20
Add "What's New" entry.
scoder May 1, 2019
c37c3db
Fix syntax warning due to invalid string escapes.
scoder May 1, 2019
6c903a3
Fix reference leaks.
scoder May 1, 2019
555593b
Move the documentation of the start_ns() and end_ns() methods to a mo…
scoder May 1, 2019
b1aadb8
Merge branch 'bpo-36676_etree_startns' into bpo-13611_et_c14n2
scoder May 1, 2019
03bd37e
Merge branch 'master' into bpo-36676_etree_startns
scoder May 1, 2019
19b3f5a
Merge branch 'bpo-36676_etree_startns' into bpo-13611_et_c14n2
scoder May 1, 2019
647fd77
Merge branch master into bpo-13611_et_c14n2
scoder May 1, 2019
56b6428
Add missing "versionadded" tag in docs.
scoder May 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update documentation now that canonicalize() supports file paths as i…
…nput.
  • Loading branch information
scoder committed Apr 29, 2019
commit a94b07d7d13a3591c5482451533c28ee4672cb95
14 changes: 9 additions & 5 deletions Doc/library/xml.etree.elementtree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,12 @@ Functions
representation. The main restrictions regard the placement of namespace
declarations, the ordering of attributes, and ignorable whitespace.

This function takes an XML data string (*xml_data*) or a file-like object
(*from_file*) as input, converts it to the canonical form, and writes it
out using the *out* file(-like) object, if provided, or returns it as a
text string if not. The output file receives text, not bytes. It should
therefore be opened in text mode with ``utf-8`` encoding.
This function takes an XML data string (*xml_data*) or a file path or
file-like object (*from_file*) as input, converts it to the canonical
form, and writes it out using the *out* file(-like) object, if provided,
or returns it as a text string if not. The output file receives text,
not bytes. It should therefore be opened in text mode with ``utf-8``
encoding.

Typical uses::

Expand All @@ -489,6 +490,9 @@ Functions
with open("c14n_output.xml", mode='w', encoding='utf-8') as out_file:
canonicalize(xml_data, out=out_file)

with open("c14n_output.xml", mode='w', encoding='utf-8') as out_file:
canonicalize(from_file="inputfile.xml", out=out_file)

The configuration *options* are as follows:

- *with_comments*: set to true to include comments (default: false)
Expand Down
4 changes: 2 additions & 2 deletions Lib/xml/etree/ElementTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,8 +1723,8 @@ def canonicalize(xml_data=None, *, out=None, from_file=None, **options):
method. To write to a file, open it in text mode with encoding "utf-8".
If *out* is not provided, this function returns the output as text string.

Either *xml_data* (an XML string) or *from_file* (a file-like object)
must be provided as input.
Either *xml_data* (an XML string) or *from_file* (a file path or
file-like object) must be provided as input.

The configuration options are the same as for the ``C14NWriterTarget``.
"""
Expand Down