Browse Source

Include fix for XML output formatting being minified in the last two tests

Removed needless elipses
Replace elipses with <BLANKLINE>
Remove doctest: +SKIP (oops)
pull/3/head
Jason Morgan 3 weeks ago
parent
commit
de2e7f0791
2 changed files with 5 additions and 6 deletions
  1. +1
    -0
      pypeg2/xmlast.py
  2. +4
    -6
      samples/sample2.py

+ 1
- 0
pypeg2/xmlast.py View File

@ -126,6 +126,7 @@ def thing2xml(thing, pretty=False, object_names=False):
if pretty:
warnings.warn("lxml is needed for pretty printing",
ImportWarning)
etree.indent(tree)
return etree.tostring(tree)


+ 4
- 6
samples/sample2.py View File

@ -48,7 +48,7 @@ that=new one
once=anything
twice=goes
[Number 3]
...
<BLANKLINE>
pyPEG contains an XML backend, too:
@ -63,14 +63,13 @@ pyPEG contains an XML backend, too:
<Key name="once">anything</Key>
<Key name="twice">goes</Key>
</Section>
<Section name="Number 3"/>
<Section name="Number 3" />
</IniFile>
...
In this sample the tree contains named objects only. Then we can output object
names as tag names. Spaces in names will be translated into underscores.
>>> print(thing2xml(ini_file, pretty=True, object_names=True).decode()) # doctest: +SKIP
>>> print(thing2xml(ini_file, pretty=True, object_names=True).decode())
<IniFile>
<Number_1>
<this>something</this>
@ -80,9 +79,8 @@ names as tag names. Spaces in names will be translated into underscores.
<once>anything</once>
<twice>goes</twice>
</Number_2>
<Number_3/>
<Number_3 />
</IniFile>
...
"""
from __future__ import unicode_literals, print_function


Loading…
Cancel
Save