[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-08-23 Thread Stefan Behnel


Change by Stefan Behnel :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-08-23 Thread Stefan Behnel


Stefan Behnel  added the comment:


New changeset b5d3ceea48c181b3e2c6c67424317afed606bd39 by Stefan Behnel in 
branch 'master':
bpo-14465: Add an indent() function to xml.etree.ElementTree to pretty-print 
XML trees (GH-15200)
https://github.com/python/cpython/commit/b5d3ceea48c181b3e2c6c67424317afed606bd39


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-08-12 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-08-10 Thread Stefan Behnel


Change by Stefan Behnel :


--
pull_requests: +14929
pull_request: https://github.com/python/cpython/pull/15200

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-08-10 Thread Stefan Behnel


Stefan Behnel  added the comment:

The spec section that Raymond quoted makes it clear that pretty printing is not 
for everyone. But there are many use cases where it is 1) helpful, 2) leads to 
correct results, and 3) does not grow the file size excessively. Whoever wants 
to make use of it is probably in such a situation. I think adding some kind of 
support in the standard library would be nice, but it should not hurt "normal" 
uses, especially when a lot of data is involved.

I'll send a PR that adds an indent() function to pre-process trees. Comments 
welcome.

--
assignee: serhiy.storchaka -> scoder
versions: +Python 3.9 -Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-08-09 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

FWIW, here is the relevant section of the XML specification, 
https://www.w3.org/TR/2008/REC-xml-20081126/#sec-white-space :

"""In editing XML documents, it is often convenient to use "white space" 
(spaces, tabs, and blank lines) to set apart the markup for greater 
readability. Such white space is typically not intended for inclusion in the 
delivered version of the document. On the other hand, "significant" white space 
that should be preserved in the delivered version is common, for example in 
poetry and source code.

An XML processor must always pass all characters in a document that are not 
markup through to the application. A validating XML processor must also inform 
the application which of these characters constitute white space appearing in 
element content.
"""

OTOH, the java TransformerFactory does support a property, OutputKeys.INDENT, 
so there is a precedent for this feature request.

Stefan, would you please make a final determination or pronouncement on whether 
this makes sense for ElementTree or whether it is outside the scope of what the 
module is trying to accomplish.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-08-08 Thread Andrew Grant


Change by Andrew Grant :


--
nosy: +Andrew Grant

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-06-22 Thread Mitar


Change by Mitar :


--
nosy: +mitar

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2019-02-12 Thread Clayton Olney


Clayton Olney  added the comment:

I have a use case where the receiving application is expecting the indentation, 
and I need to run my code in Lambda. So, lxml is out of the question.

--
nosy: +Clayton Olney

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2018-08-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

A few more thoughts for consideration:

* We already have a toprettyxml() tool in the minidom package.

* Since whitespace is significant in XML, prettifying changes the content and 
meaning, so it doesn't round-trip and should only be used for debugging 
purposes.

* Usually, I recommend using XML viewers such as the one built into the Chrome 
browser.  That provides indentation without changing meaning. It also lets you 
run searches and conveniently supports folding and unfolding elements.   I 
would rather someone use a viewer rather than something like toprettyxml().

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2018-08-25 Thread Matej Cepl


Change by Matej Cepl :


--
pull_requests: +8405

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2018-08-17 Thread Stefan Behnel


Stefan Behnel  added the comment:

> Serialization of ElementTree in the stdlib is much slower than in lxml (see 
> issue25881). Perhaps it should be implemented in C. But it should be kept 
> simple for this.

Should I say it? That's a first class use case for Cython.


> Pretty-printing can be implemented as an outher preprocessing operation

Agreed. And that would actually be much simpler to implement in C.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2018-08-17 Thread Matej Cepl


Change by Matej Cepl :


--
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2017-10-24 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

My thoughts:

1. Whitespaces are significant in XML. Pretty-printed XML is different from the 
original XML to an XML parser. For some applications some whitespaces around 
tags are not significant. But this depends on the application and in different 
parts of the document whitespaces can have different meaning. For example the 
document can contain a metadata with insignificant whitespaces and marked up 
text with significant whitespaces. There is a special attribute named xml:space 
that can signal the meaning of whitespaces for the part of a document.

https://www.w3.org/TR/xml/#sec-white-space

2. In HTML whitespaces around  are insignificant, but whitespaces around  
are significant. Whitespaces inside ... are significant.

3. If strip whitespaces around tags and insert newlines and indentations, 
shouldn't we strip whitespaces inside the text context? Or preserve newlines 
but update indentations?

4. If modify whitespaces on output, it may be worth to add an option to ignore 
insignificant whitespaces on input.

5. Serialization of ElementTree in the stdlib is much slower than in lxml (see 
issue25881). Perhaps it should be implemented in C. But it should be kept 
simple for this. Pretty-printing can be implemented as an outher preprocessing 
operation (for example the original Eli's code indents the tree in-place: 
http://effbot.org/zone/element-lib.htm#prettyprint) or as a proxy that indents 
elements on-fly.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2017-10-22 Thread Wolfgang Maier

Change by Wolfgang Maier :


--
nosy: +wolma

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2017-10-18 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
components: +XML
nosy: +serhiy.storchaka
versions: +Python 3.7 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2017-10-17 Thread Alex Dzyoba

Change by Alex Dzyoba :


--
pull_requests: +3990
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2017-10-14 Thread Alex Dzyoba

Change by Alex Dzyoba :


--
nosy: +alexdzyoba

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2017-10-13 Thread STINNER Victor

STINNER Victor  added the comment:

For the record, at 2015-04-02, the bpo-23847 has been marked as a duplicate of 
this issue.

--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2015-01-27 Thread Matej Cepl

Changes by Matej Cepl mc...@redhat.com:


--
nosy: +mcepl

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2015-01-27 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2013-08-11 Thread Stefan Behnel

Stefan Behnel added the comment:

Just to reiterate this point, lxml.etree supports a pretty_print flag in its 
tostring() function and ElementTree.write(). It would thus make sense to 
support the same thing in ET.

http://lxml.de/api.html#serialisation

For completeness, the current signature looks like this:

def tostring(element_or_tree, *, encoding=None, method=xml,
 xml_declaration=None, pretty_print=False,
 with_tail=True, standalone=None, doctype=None,
 exclusive=False, with_comments=True,
 inclusive_ns_prefixes=None):

(The last three options are for C14N serialisation.)

--
nosy: +scoder
versions: +Python 3.4 -Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2013-08-11 Thread Eric Snow

Changes by Eric Snow ericsnowcurren...@gmail.com:


--
nosy: +eric.snow

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2013-08-05 Thread Alex Henderson

Alex Henderson added the comment:

Proposed patch copied over from duplicate issue 17372.

--
keywords: +patch
nosy: +alex.henderson
Added file: http://bugs.python.org/file31168/issue14465.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

A patch exists in the duplicate #17372

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2012-04-06 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

You may be able to code it entirely in the Python part of the module (adding a 
new parameter to Element.write and tostring).

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2012-04-05 Thread Santoso Wijaya

Changes by Santoso Wijaya santoso.wij...@gmail.com:


--
nosy: +santa4nt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2012-04-01 Thread Tshepang Lekhonkhobe

Changes by Tshepang Lekhonkhobe tshep...@gmail.com:


--
title: add feature to prettify XML output - xml.etree.ElementTree: add feature 
to prettify XML output

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2012-04-01 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
type:  - enhancement

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2012-04-01 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

Would you like to provide a patch?

--
nosy: +loewis

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2012-04-01 Thread Eli Bendersky

Eli Bendersky eli...@gmail.com added the comment:

Tshepang,

Frankly, there are a lot of issues to solve in ElementTree (it hasn't been 
given love in a long time...) and such features would be low priority, as I'm 
not getting much help and am swamped already.

As Martin said, patches can go a long way here...

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2012-04-01 Thread Tshepang Lekhonkhobe

Tshepang Lekhonkhobe tshep...@gmail.com added the comment:

Okay, I will try, even though C scares me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com