Hello community,
here is the log from the commit of package python-xmltodict for
openSUSE:Factory checked in at 2019-03-26 15:46:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-xmltodict (Old)
and /work/SRC/openSUSE:Factory/.python-xmltodict.new.25356 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-xmltodict"
Tue Mar 26 15:46:05 2019 rev:3 rq:688692 version:0.12.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-xmltodict/python-xmltodict.changes
2018-12-13 19:45:34.844923840 +0100
+++
/work/SRC/openSUSE:Factory/.python-xmltodict.new.25356/python-xmltodict.changes
2019-03-26 15:46:06.996061546 +0100
@@ -1,0 +2,20 @@
+Tue Mar 26 12:20:55 UTC 2019 - Jan Engelhardt <[email protected]>
+
+- Use noun phrase in summary.
+
+-------------------------------------------------------------------
+Tue Mar 26 11:02:52 UTC 2019 - [email protected]
+
+- version update to 0.12.0
+ * Allow force_commits=True for getting all keys as lists (#204)
+ * README.md: fix useless uses of cat (#200)
+ * Add FreeBSD install instructions (#199)
+ * Fix and simplify travis config (#192)
+ * Add support for Python 3.7 (#189)
+ * Drop support for EOL Python (#191)
+ * Use Markdown long_description on PyPI (#190)
+ * correct spelling mistake (#165)
+ * correctly unparse booleans (#180)
+ * Updates README.md with svg badge
+
+-------------------------------------------------------------------
Old:
----
xmltodict-0.11.0.tar.gz
New:
----
xmltodict-0.12.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-xmltodict.spec ++++++
--- /var/tmp/diff_new_pack.Dcoqru/_old 2019-03-26 15:46:08.412060829 +0100
+++ /var/tmp/diff_new_pack.Dcoqru/_new 2019-03-26 15:46:08.448060810 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-xmltodict
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,11 +17,10 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%bcond_without test
Name: python-xmltodict
-Version: 0.11.0
+Version: 0.12.0
Release: 0
-Summary: Makes working with XML feel like you are working with JSON
+Summary: Module to make XML working resemble JSON
License: MIT
Group: Development/Languages/Python
URL: https://github.com/martinblech/xmltodict
@@ -32,9 +31,7 @@
BuildRequires: python-rpm-macros
Requires: python-xml
BuildArch: noarch
-%if %{with test}
BuildRequires: %{python_module nose >= 1.0}
-%endif
%python_subpackages
%description
@@ -53,10 +50,8 @@
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
-%if %{with test}
%check
%python_expand nosetests-%{$python_bin_suffix}
-%endif
%files %{python_files}
%license LICENSE
++++++ xmltodict-0.11.0.tar.gz -> xmltodict-0.12.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/PKG-INFO
new/xmltodict-0.12.0/PKG-INFO
--- old/xmltodict-0.11.0/PKG-INFO 2017-04-27 20:59:03.000000000 +0200
+++ new/xmltodict-0.12.0/PKG-INFO 2019-02-11 08:00:08.000000000 +0100
@@ -1,27 +1,232 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: xmltodict
-Version: 0.11.0
+Version: 0.12.0
Summary: Makes working with XML feel like you are working with JSON
Home-page: https://github.com/martinblech/xmltodict
Author: Martin Blech
Author-email: [email protected]
License: MIT
-Description: UNKNOWN
+Description: # xmltodict
+
+ `xmltodict` is a Python module that makes working with XML feel like
you are working with [JSON](http://docs.python.org/library/json.html), as in
this
["spec"](http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html):
+
+ [](http://travis-ci.org/martinblech/xmltodict)
+
+ ```python
+ >>> print(json.dumps(xmltodict.parse("""
+ ... <mydocument has="an attribute">
+ ... <and>
+ ... <many>elements</many>
+ ... <many>more elements</many>
+ ... </and>
+ ... <plus a="complex">
+ ... element as well
+ ... </plus>
+ ... </mydocument>
+ ... """), indent=4))
+ {
+ "mydocument": {
+ "@has": "an attribute",
+ "and": {
+ "many": [
+ "elements",
+ "more elements"
+ ]
+ },
+ "plus": {
+ "@a": "complex",
+ "#text": "element as well"
+ }
+ }
+ }
+ ```
+
+ ## Namespace support
+
+ By default, `xmltodict` does no XML namespace processing (it just
treats namespace declarations as regular node attributes), but passing
`process_namespaces=True` will make it expand namespaces for you:
+
+ ```python
+ >>> xml = """
+ ... <root xmlns="http://defaultns.com/"
+ ... xmlns:a="http://a.com/"
+ ... xmlns:b="http://b.com/">
+ ... <x>1</x>
+ ... <a:y>2</a:y>
+ ... <b:z>3</b:z>
+ ... </root>
+ ... """
+ >>> xmltodict.parse(xml, process_namespaces=True) == {
+ ... 'http://defaultns.com/:root': {
+ ... 'http://defaultns.com/:x': '1',
+ ... 'http://a.com/:y': '2',
+ ... 'http://b.com/:z': '3',
+ ... }
+ ... }
+ True
+ ```
+
+ It also lets you collapse certain namespaces to shorthand prefixes, or
skip them altogether:
+
+ ```python
+ >>> namespaces = {
+ ... 'http://defaultns.com/': None, # skip this namespace
+ ... 'http://a.com/': 'ns_a', # collapse "http://a.com/" -> "ns_a"
+ ... }
+ >>> xmltodict.parse(xml, process_namespaces=True,
namespaces=namespaces) == {
+ ... 'root': {
+ ... 'x': '1',
+ ... 'ns_a:y': '2',
+ ... 'http://b.com/:z': '3',
+ ... },
+ ... }
+ True
+ ```
+
+ ## Streaming mode
+
+ `xmltodict` is very fast
([Expat](http://docs.python.org/library/pyexpat.html)-based) and has a
streaming mode with a small memory footprint, suitable for big XML dumps like
[Discogs](http://discogs.com/data/) or [Wikipedia](http://dumps.wikimedia.org/):
+
+ ```python
+ >>> def handle_artist(_, artist):
+ ... print(artist['name'])
+ ... return True
+ >>>
+ >>> xmltodict.parse(GzipFile('discogs_artists.xml.gz'),
+ ... item_depth=2, item_callback=handle_artist)
+ A Perfect Circle
+ Fantômas
+ King Crimson
+ Chris Potter
+ ...
+ ```
+
+ It can also be used from the command line to pipe objects to a script
like this:
+
+ ```python
+ import sys, marshal
+ while True:
+ _, article = marshal.load(sys.stdin)
+ print(article['title'])
+ ```
+
+ ```sh
+ $ bunzip2 enwiki-pages-articles.xml.bz2 | xmltodict.py 2 | myscript.py
+ AccessibleComputing
+ Anarchism
+ AfghanistanHistory
+ AfghanistanGeography
+ AfghanistanPeople
+ AfghanistanCommunications
+ Autism
+ ...
+ ```
+
+ Or just cache the dicts so you don't have to parse that big XML file
again. You do this only once:
+
+ ```sh
+ $ bunzip2 enwiki-pages-articles.xml.bz2 | xmltodict.py 2 | gzip >
enwiki.dicts.gz
+ ```
+
+ And you reuse the dicts with every script that needs them:
+
+ ```sh
+ $ gunzip enwiki.dicts.gz | script1.py
+ $ gunzip enwiki.dicts.gz | script2.py
+ ...
+ ```
+
+ ## Roundtripping
+
+ You can also convert in the other direction, using the `unparse()`
method:
+
+ ```python
+ >>> mydict = {
+ ... 'response': {
+ ... 'status': 'good',
+ ... 'last_updated': '2014-02-16T23:10:12Z',
+ ... }
+ ... }
+ >>> print(unparse(mydict, pretty=True))
+ <?xml version="1.0" encoding="utf-8"?>
+ <response>
+ <status>good</status>
+ <last_updated>2014-02-16T23:10:12Z</last_updated>
+ </response>
+ ```
+
+ Text values for nodes can be specified with the `cdata_key` key in the
python dict, while node properties can be specified with the `attr_prefix`
prefixed to the key name in the python dict. The default value for
`attr_prefix` is `@` and the default value for `cdata_key` is `#text`.
+
+ ```python
+ >>> import xmltodict
+ >>>
+ >>> mydict = {
+ ... 'text': {
+ ... '@color':'red',
+ ... '@stroke':'2',
+ ... '#text':'This is a test'
+ ... }
+ ... }
+ >>> print(xmltodict.unparse(mydict, pretty=True))
+ <?xml version="1.0" encoding="utf-8"?>
+ <text stroke="2" color="red">This is a test</text>
+ ```
+
+ ## Ok, how do I get it?
+
+ ### Using pypi
+
+ You just need to
+
+ ```sh
+ $ pip install xmltodict
+ ```
+
+ ### RPM-based distro (Fedora, RHEL, …)
+
+ There is an [official Fedora package for
xmltodict](https://apps.fedoraproject.org/packages/python-xmltodict).
+
+ ```sh
+ $ sudo yum install python-xmltodict
+ ```
+
+ ### Arch Linux
+
+ There is an [official Arch Linux package for
xmltodict](https://www.archlinux.org/packages/community/any/python-xmltodict/).
+
+ ```sh
+ $ sudo pacman -S python-xmltodict
+ ```
+
+ ### Debian-based distro (Debian, Ubuntu, …)
+
+ There is an [official Debian package for
xmltodict](https://tracker.debian.org/pkg/python-xmltodict).
+
+ ```sh
+ $ sudo apt install python-xmltodict
+ ```
+
+ ### FreeBSD
+
+ There is an [official FreeBSD port for
xmltodict](https://svnweb.freebsd.org/ports/head/devel/py-xmltodict/).
+
+ ```sh
+ $ pkg install py36-xmltodict
+ ```
+
Platform: all
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.5
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: Jython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Text Processing :: Markup :: XML
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/README.md
new/xmltodict-0.12.0/README.md
--- old/xmltodict-0.11.0/README.md 2016-10-26 06:07:06.000000000 +0200
+++ new/xmltodict-0.12.0/README.md 2019-02-11 07:36:33.000000000 +0100
@@ -2,7 +2,7 @@
`xmltodict` is a Python module that makes working with XML feel like you are
working with [JSON](http://docs.python.org/library/json.html), as in this
["spec"](http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html):
-[](http://travis-ci.org/martinblech/xmltodict)
+[](http://travis-ci.org/martinblech/xmltodict)
```python
>>> print(json.dumps(xmltodict.parse("""
@@ -102,7 +102,7 @@
```
```sh
-$ cat enwiki-pages-articles.xml.bz2 | bunzip2 | xmltodict.py 2 | myscript.py
+$ bunzip2 enwiki-pages-articles.xml.bz2 | xmltodict.py 2 | myscript.py
AccessibleComputing
Anarchism
AfghanistanHistory
@@ -116,14 +116,14 @@
Or just cache the dicts so you don't have to parse that big XML file again.
You do this only once:
```sh
-$ cat enwiki-pages-articles.xml.bz2 | bunzip2 | xmltodict.py 2 | gzip >
enwiki.dicts.gz
+$ bunzip2 enwiki-pages-articles.xml.bz2 | xmltodict.py 2 | gzip >
enwiki.dicts.gz
```
And you reuse the dicts with every script that needs them:
```sh
-$ cat enwiki.dicts.gz | gunzip | script1.py
-$ cat enwiki.dicts.gz | gunzip | script2.py
+$ gunzip enwiki.dicts.gz | script1.py
+$ gunzip enwiki.dicts.gz | script2.py
...
```
@@ -175,7 +175,7 @@
### RPM-based distro (Fedora, RHEL, …)
-There is an [official Fedora package for
xmltodict](https://admin.fedoraproject.org/pkgdb/acls/name/python-xmltodict).
+There is an [official Fedora package for
xmltodict](https://apps.fedoraproject.org/packages/python-xmltodict).
```sh
$ sudo yum install python-xmltodict
@@ -196,3 +196,11 @@
```sh
$ sudo apt install python-xmltodict
```
+
+### FreeBSD
+
+There is an [official FreeBSD port for
xmltodict](https://svnweb.freebsd.org/ports/head/devel/py-xmltodict/).
+
+```sh
+$ pkg install py36-xmltodict
+```
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/ez_setup.py
new/xmltodict-0.12.0/ez_setup.py
--- old/xmltodict-0.11.0/ez_setup.py 2016-02-23 06:00:58.000000000 +0100
+++ new/xmltodict-0.12.0/ez_setup.py 2019-02-11 07:36:33.000000000 +0100
@@ -3,7 +3,11 @@
"""
Setuptools bootstrapping installer.
+Maintained at https://github.com/pypa/setuptools/tree/bootstrap.
+
Run this script to install or upgrade setuptools.
+
+This method is DEPRECATED. Check https://github.com/pypa/setuptools/issues/581
for more details.
"""
import os
@@ -16,8 +20,6 @@
import platform
import textwrap
import contextlib
-import json
-import codecs
from distutils import log
@@ -31,10 +33,15 @@
except ImportError:
USER_SITE = None
-LATEST = object()
-DEFAULT_VERSION = LATEST
-DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
+# 33.1.1 is the last version that supports setuptools self
upgrade/installation.
+DEFAULT_VERSION = "33.1.1"
+DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/"
DEFAULT_SAVE_DIR = os.curdir
+DEFAULT_DEPRECATION_MESSAGE = "ez_setup.py is deprecated and when using it
setuptools will be pinned to {0} since it's the last version that supports
setuptools self upgrade/installation, check
https://github.com/pypa/setuptools/issues/581 for more info; use pip to install
setuptools"
+
+MEANINGFUL_INVALID_ZIP_ERR_MSG = 'Maybe {0} is corrupted, delete it and try
again.'
+
+log.warn(DEFAULT_DEPRECATION_MESSAGE.format(DEFAULT_VERSION))
def _python_cmd(*args):
@@ -100,8 +107,16 @@
old_wd = os.getcwd()
try:
os.chdir(tmpdir)
- with ContextualZipFile(filename) as archive:
- archive.extractall()
+ try:
+ with ContextualZipFile(filename) as archive:
+ archive.extractall()
+ except zipfile.BadZipfile as err:
+ if not err.args:
+ err.args = ('', )
+ err.args = err.args + (
+ MEANINGFUL_INVALID_ZIP_ERR_MSG.format(filename),
+ )
+ raise
# going in the directory
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
@@ -116,11 +131,12 @@
def _do_download(version, download_base, to_dir, download_delay):
"""Download Setuptools."""
- egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg'
- % (version, sys.version_info[0], sys.version_info[1]))
+ py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)
+ tp = 'setuptools-{version}-{py_desig}.egg'
+ egg = os.path.join(to_dir, tp.format(**locals()))
if not os.path.exists(egg):
archive = download_setuptools(version, download_base,
- to_dir, download_delay)
+ to_dir, download_delay)
_build_egg(egg, archive, to_dir)
sys.path.insert(0, egg)
@@ -142,7 +158,6 @@
Return None. Raise SystemExit if the requested version
or later cannot be installed.
"""
- version = _resolve_version(version)
to_dir = os.path.abspath(to_dir)
# prior to importing, capture the module state for
@@ -192,6 +207,11 @@
def _unload_pkg_resources():
+ sys.meta_path = [
+ importer
+ for importer in sys.meta_path
+ if importer.__class__.__module__ != 'pkg_resources.extern'
+ ]
del_modules = [
name for name in sys.modules
if name.startswith('pkg_resources')
@@ -251,7 +271,7 @@
def download_file_curl(url, target):
- cmd = ['curl', url, '--silent', '--output', target]
+ cmd = ['curl', url, '--location', '--silent', '--output', target]
_clean_check(cmd, target)
@@ -324,7 +344,6 @@
``downloader_factory`` should be a function taking no arguments and
returning a function for downloading a URL to a target.
"""
- version = _resolve_version(version)
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
zip_name = "setuptools-%s.zip" % version
@@ -337,26 +356,6 @@
return os.path.realpath(saveto)
-def _resolve_version(version):
- """
- Resolve LATEST version
- """
- if version is not LATEST:
- return version
-
- resp = urlopen('https://pypi.python.org/pypi/setuptools/json')
- with contextlib.closing(resp):
- try:
- charset = resp.info().get_content_charset()
- except Exception:
- # Python 2 compat; assume UTF-8
- charset = 'UTF-8'
- reader = codecs.getreader(charset)
- doc = json.load(reader(resp))
-
- return str(doc['info']['version'])
-
-
def _build_install_args(options):
"""
Build the arguments to 'python setup.py install' on the setuptools package.
@@ -371,7 +370,7 @@
parser = optparse.OptionParser()
parser.add_option(
'--user', dest='user_install', action='store_true', default=False,
- help='install in user site package (requires Python 2.6 or later)')
+ help='install in user site package')
parser.add_option(
'--download-base', dest='download_base', metavar="URL",
default=DEFAULT_URL,
@@ -386,9 +385,9 @@
default=DEFAULT_VERSION,
)
parser.add_option(
- '--to-dir',
- help="Directory to save (and re-use) package",
- default=DEFAULT_SAVE_DIR,
+ '--to-dir',
+ help="Directory to save (and re-use) package",
+ default=DEFAULT_SAVE_DIR,
)
options, args = parser.parse_args()
# positional arguments are ignored
@@ -396,13 +395,13 @@
def _download_args(options):
- """Return args for download_setuptools function from cmdline args."""
- return dict(
- version=options.version,
- download_base=options.download_base,
- downloader_factory=options.downloader_factory,
- to_dir=options.to_dir,
- )
+ """Return args for download_setuptools function from cmdline args."""
+ return dict(
+ version=options.version,
+ download_base=options.download_base,
+ downloader_factory=options.downloader_factory,
+ to_dir=options.to_dir,
+ )
def main():
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/setup.cfg
new/xmltodict-0.12.0/setup.cfg
--- old/xmltodict-0.11.0/setup.cfg 2017-04-27 20:59:04.000000000 +0200
+++ new/xmltodict-0.12.0/setup.cfg 2019-02-11 08:00:08.000000000 +0100
@@ -4,5 +4,4 @@
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/setup.py
new/xmltodict-0.12.0/setup.py
--- old/xmltodict-0.11.0/setup.py 2017-04-27 20:19:50.000000000 +0200
+++ new/xmltodict-0.12.0/setup.py 2019-02-11 07:36:33.000000000 +0100
@@ -8,29 +8,33 @@
import xmltodict
+with open('README.md') as f:
+ long_description = f.read()
+
+
setup(name='xmltodict',
version=xmltodict.__version__,
description=xmltodict.__doc__,
+ long_description=long_description,
+ long_description_content_type='text/markdown',
author=xmltodict.__author__,
author_email='[email protected]',
url='https://github.com/martinblech/xmltodict',
license=xmltodict.__license__,
platforms=['all'],
+ python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.5',
- 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.2',
- 'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: Jython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Text Processing :: Markup :: XML',
Binary files
old/xmltodict-0.11.0/tests/__pycache__/test_dicttoxml.cpython-35.pyc and
new/xmltodict-0.12.0/tests/__pycache__/test_dicttoxml.cpython-35.pyc differ
Binary files
old/xmltodict-0.11.0/tests/__pycache__/test_xmltodict.cpython-35.pyc and
new/xmltodict-0.12.0/tests/__pycache__/test_xmltodict.cpython-35.pyc differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/tests/test_dicttoxml.py
new/xmltodict-0.12.0/tests/test_dicttoxml.py
--- old/xmltodict-0.11.0/tests/test_dicttoxml.py 2016-10-26
06:20:55.000000000 +0200
+++ new/xmltodict-0.12.0/tests/test_dicttoxml.py 2019-02-11
07:36:33.000000000 +0100
@@ -1,12 +1,9 @@
import sys
-from xmltodict import parse, unparse, OrderedDict
+from xmltodict import parse, unparse
+from collections import OrderedDict
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
+import unittest
import re
-import collections
from textwrap import dedent
IS_JYTHON = sys.platform.startswith('java')
@@ -51,11 +48,12 @@
def test_generator(self):
obj = {'a': {'b': ['1', '2', '3']}}
+
def lazy_obj():
return {'a': {'b': (i for i in ('1', '2', '3'))}}
self.assertEqual(obj, parse(unparse(lazy_obj())))
self.assertEqual(unparse(lazy_obj()),
- unparse(parse(unparse(lazy_obj()))))
+ unparse(parse(unparse(lazy_obj()))))
def test_no_root(self):
self.assertRaises(ValueError, unparse, {})
@@ -165,12 +163,11 @@
self.assertEqual('<a attr="1"></a>', _strip(unparse(obj)))
def test_short_empty_elements(self):
- if sys.version_info < (3, 2):
+ if sys.version_info[0] < 3:
return
obj = {'a': None}
self.assertEqual('<a/>', _strip(unparse(obj,
short_empty_elements=True)))
-
def test_namespace_support(self):
obj = OrderedDict((
('http://defaultns.com/:root', OrderedDict((
@@ -199,3 +196,12 @@
xml = unparse(obj, namespaces=ns)
self.assertEqual(xml, expected_xml)
+
+ def test_boolean_unparse(self):
+ expected_xml = '<?xml version="1.0" encoding="utf-8"?>\n<x>true</x>'
+ xml = unparse(dict(x=True))
+ self.assertEqual(xml, expected_xml)
+
+ expected_xml = '<?xml version="1.0" encoding="utf-8"?>\n<x>false</x>'
+ xml = unparse(dict(x=False))
+ self.assertEqual(xml, expected_xml)
Binary files old/xmltodict-0.11.0/tests/test_dicttoxml.pyc and
new/xmltodict-0.12.0/tests/test_dicttoxml.pyc differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/tests/test_xmltodict.py
new/xmltodict-0.12.0/tests/test_xmltodict.py
--- old/xmltodict-0.11.0/tests/test_xmltodict.py 2017-04-27
20:52:57.000000000 +0200
+++ new/xmltodict-0.12.0/tests/test_xmltodict.py 2019-02-11
07:36:33.000000000 +0100
@@ -1,10 +1,7 @@
from xmltodict import parse, ParsingInterrupted
+import unittest
try:
- import unittest2 as unittest
-except ImportError:
- import unittest
-try:
from io import BytesIO as StringIO
except ImportError:
from xmltodict import StringIO
@@ -12,6 +9,7 @@
from xml.parsers.expat import ParserCreate
from xml.parsers import expat
+
def _encode(s):
try:
return bytes(s, 'ascii')
@@ -286,6 +284,7 @@
</skip>
</config>
"""
+
def force_list(path, key, value):
"""Only return True for servers/server, but not for skip/server."""
if key != 'server':
@@ -361,6 +360,7 @@
]>
<root>ⅇ</root>
"""
+
def raising_external_ref_handler(*args, **kwargs):
parser = ParserCreate(*args, **kwargs)
parser.ExternalEntityRefHandler = lambda *x: 0
@@ -371,7 +371,7 @@
pass
return parser
expat.ParserCreate = raising_external_ref_handler
- # Using this try/catch because a TypeError is thrown before
+ # Using this try/catch because a TypeError is thrown before
# the ExpatError, and Python 2.6 is confused by that.
try:
parse(xml, disable_entities=False, expat=expat)
@@ -380,4 +380,3 @@
else:
self.assertTrue(False)
expat.ParserCreate = ParserCreate
-
Binary files old/xmltodict-0.11.0/tests/test_xmltodict.pyc and
new/xmltodict-0.12.0/tests/test_xmltodict.pyc differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/xmltodict.egg-info/PKG-INFO
new/xmltodict-0.12.0/xmltodict.egg-info/PKG-INFO
--- old/xmltodict-0.11.0/xmltodict.egg-info/PKG-INFO 2017-04-27
20:59:03.000000000 +0200
+++ new/xmltodict-0.12.0/xmltodict.egg-info/PKG-INFO 2019-02-11
08:00:08.000000000 +0100
@@ -1,27 +1,232 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: xmltodict
-Version: 0.11.0
+Version: 0.12.0
Summary: Makes working with XML feel like you are working with JSON
Home-page: https://github.com/martinblech/xmltodict
Author: Martin Blech
Author-email: [email protected]
License: MIT
-Description: UNKNOWN
+Description: # xmltodict
+
+ `xmltodict` is a Python module that makes working with XML feel like
you are working with [JSON](http://docs.python.org/library/json.html), as in
this
["spec"](http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html):
+
+ [](http://travis-ci.org/martinblech/xmltodict)
+
+ ```python
+ >>> print(json.dumps(xmltodict.parse("""
+ ... <mydocument has="an attribute">
+ ... <and>
+ ... <many>elements</many>
+ ... <many>more elements</many>
+ ... </and>
+ ... <plus a="complex">
+ ... element as well
+ ... </plus>
+ ... </mydocument>
+ ... """), indent=4))
+ {
+ "mydocument": {
+ "@has": "an attribute",
+ "and": {
+ "many": [
+ "elements",
+ "more elements"
+ ]
+ },
+ "plus": {
+ "@a": "complex",
+ "#text": "element as well"
+ }
+ }
+ }
+ ```
+
+ ## Namespace support
+
+ By default, `xmltodict` does no XML namespace processing (it just
treats namespace declarations as regular node attributes), but passing
`process_namespaces=True` will make it expand namespaces for you:
+
+ ```python
+ >>> xml = """
+ ... <root xmlns="http://defaultns.com/"
+ ... xmlns:a="http://a.com/"
+ ... xmlns:b="http://b.com/">
+ ... <x>1</x>
+ ... <a:y>2</a:y>
+ ... <b:z>3</b:z>
+ ... </root>
+ ... """
+ >>> xmltodict.parse(xml, process_namespaces=True) == {
+ ... 'http://defaultns.com/:root': {
+ ... 'http://defaultns.com/:x': '1',
+ ... 'http://a.com/:y': '2',
+ ... 'http://b.com/:z': '3',
+ ... }
+ ... }
+ True
+ ```
+
+ It also lets you collapse certain namespaces to shorthand prefixes, or
skip them altogether:
+
+ ```python
+ >>> namespaces = {
+ ... 'http://defaultns.com/': None, # skip this namespace
+ ... 'http://a.com/': 'ns_a', # collapse "http://a.com/" -> "ns_a"
+ ... }
+ >>> xmltodict.parse(xml, process_namespaces=True,
namespaces=namespaces) == {
+ ... 'root': {
+ ... 'x': '1',
+ ... 'ns_a:y': '2',
+ ... 'http://b.com/:z': '3',
+ ... },
+ ... }
+ True
+ ```
+
+ ## Streaming mode
+
+ `xmltodict` is very fast
([Expat](http://docs.python.org/library/pyexpat.html)-based) and has a
streaming mode with a small memory footprint, suitable for big XML dumps like
[Discogs](http://discogs.com/data/) or [Wikipedia](http://dumps.wikimedia.org/):
+
+ ```python
+ >>> def handle_artist(_, artist):
+ ... print(artist['name'])
+ ... return True
+ >>>
+ >>> xmltodict.parse(GzipFile('discogs_artists.xml.gz'),
+ ... item_depth=2, item_callback=handle_artist)
+ A Perfect Circle
+ Fantômas
+ King Crimson
+ Chris Potter
+ ...
+ ```
+
+ It can also be used from the command line to pipe objects to a script
like this:
+
+ ```python
+ import sys, marshal
+ while True:
+ _, article = marshal.load(sys.stdin)
+ print(article['title'])
+ ```
+
+ ```sh
+ $ bunzip2 enwiki-pages-articles.xml.bz2 | xmltodict.py 2 | myscript.py
+ AccessibleComputing
+ Anarchism
+ AfghanistanHistory
+ AfghanistanGeography
+ AfghanistanPeople
+ AfghanistanCommunications
+ Autism
+ ...
+ ```
+
+ Or just cache the dicts so you don't have to parse that big XML file
again. You do this only once:
+
+ ```sh
+ $ bunzip2 enwiki-pages-articles.xml.bz2 | xmltodict.py 2 | gzip >
enwiki.dicts.gz
+ ```
+
+ And you reuse the dicts with every script that needs them:
+
+ ```sh
+ $ gunzip enwiki.dicts.gz | script1.py
+ $ gunzip enwiki.dicts.gz | script2.py
+ ...
+ ```
+
+ ## Roundtripping
+
+ You can also convert in the other direction, using the `unparse()`
method:
+
+ ```python
+ >>> mydict = {
+ ... 'response': {
+ ... 'status': 'good',
+ ... 'last_updated': '2014-02-16T23:10:12Z',
+ ... }
+ ... }
+ >>> print(unparse(mydict, pretty=True))
+ <?xml version="1.0" encoding="utf-8"?>
+ <response>
+ <status>good</status>
+ <last_updated>2014-02-16T23:10:12Z</last_updated>
+ </response>
+ ```
+
+ Text values for nodes can be specified with the `cdata_key` key in the
python dict, while node properties can be specified with the `attr_prefix`
prefixed to the key name in the python dict. The default value for
`attr_prefix` is `@` and the default value for `cdata_key` is `#text`.
+
+ ```python
+ >>> import xmltodict
+ >>>
+ >>> mydict = {
+ ... 'text': {
+ ... '@color':'red',
+ ... '@stroke':'2',
+ ... '#text':'This is a test'
+ ... }
+ ... }
+ >>> print(xmltodict.unparse(mydict, pretty=True))
+ <?xml version="1.0" encoding="utf-8"?>
+ <text stroke="2" color="red">This is a test</text>
+ ```
+
+ ## Ok, how do I get it?
+
+ ### Using pypi
+
+ You just need to
+
+ ```sh
+ $ pip install xmltodict
+ ```
+
+ ### RPM-based distro (Fedora, RHEL, …)
+
+ There is an [official Fedora package for
xmltodict](https://apps.fedoraproject.org/packages/python-xmltodict).
+
+ ```sh
+ $ sudo yum install python-xmltodict
+ ```
+
+ ### Arch Linux
+
+ There is an [official Arch Linux package for
xmltodict](https://www.archlinux.org/packages/community/any/python-xmltodict/).
+
+ ```sh
+ $ sudo pacman -S python-xmltodict
+ ```
+
+ ### Debian-based distro (Debian, Ubuntu, …)
+
+ There is an [official Debian package for
xmltodict](https://tracker.debian.org/pkg/python-xmltodict).
+
+ ```sh
+ $ sudo apt install python-xmltodict
+ ```
+
+ ### FreeBSD
+
+ There is an [official FreeBSD port for
xmltodict](https://svnweb.freebsd.org/ports/head/devel/py-xmltodict/).
+
+ ```sh
+ $ pkg install py36-xmltodict
+ ```
+
Platform: all
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.5
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: Jython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Text Processing :: Markup :: XML
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/xmltodict.egg-info/SOURCES.txt
new/xmltodict-0.12.0/xmltodict.egg-info/SOURCES.txt
--- old/xmltodict-0.11.0/xmltodict.egg-info/SOURCES.txt 2017-04-27
20:59:03.000000000 +0200
+++ new/xmltodict-0.12.0/xmltodict.egg-info/SOURCES.txt 2019-02-11
08:00:08.000000000 +0100
@@ -6,11 +6,7 @@
setup.py
xmltodict.py
tests/test_dicttoxml.py
-tests/test_dicttoxml.pyc
tests/test_xmltodict.py
-tests/test_xmltodict.pyc
-tests/__pycache__/test_dicttoxml.cpython-35.pyc
-tests/__pycache__/test_xmltodict.cpython-35.pyc
xmltodict.egg-info/PKG-INFO
xmltodict.egg-info/SOURCES.txt
xmltodict.egg-info/dependency_links.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmltodict-0.11.0/xmltodict.py
new/xmltodict-0.12.0/xmltodict.py
--- old/xmltodict-0.11.0/xmltodict.py 2017-04-27 20:52:57.000000000 +0200
+++ new/xmltodict-0.12.0/xmltodict.py 2019-02-11 07:57:59.000000000 +0100
@@ -14,13 +14,8 @@
from StringIO import StringIO
except ImportError:
from io import StringIO
-try: # pragma no cover
- from collections import OrderedDict
-except ImportError: # pragma no cover
- try:
- from ordereddict import OrderedDict
- except ImportError:
- OrderedDict = dict
+
+from collections import OrderedDict
try: # pragma no cover
_basestring = basestring
@@ -32,7 +27,7 @@
_unicode = str
__author__ = 'Martin Blech'
-__version__ = '0.11.0'
+__version__ = '0.12.0'
__license__ = 'MIT'
@@ -181,6 +176,8 @@
def _should_force_list(self, key, value):
if not self.force_list:
return False
+ if isinstance(self.force_list, bool):
+ return self.force_list
try:
return key in self.force_list
except TypeError:
@@ -340,7 +337,7 @@
pass
else:
ns_res = namespaces.get(ns.strip(attr_prefix))
- name = '{0}{1}{2}{3}'.format(
+ name = '{}{}{}{}'.format(
attr_prefix if ns.startswith(attr_prefix) else '',
ns_res, ns_sep, name) if ns_res else name
return name
@@ -372,6 +369,11 @@
raise ValueError('document with multiple roots')
if v is None:
v = OrderedDict()
+ elif isinstance(v, bool):
+ if v:
+ v = _unicode('true')
+ else:
+ v = _unicode('false')
elif not isinstance(v, dict):
v = _unicode(v)
if isinstance(v, _basestring):
@@ -388,7 +390,7 @@
attr_prefix)
if ik == '@xmlns' and isinstance(iv, dict):
for k, v in iv.items():
- attr = 'xmlns{0}'.format(':{0}'.format(k) if k else '')
+ attr = 'xmlns{}'.format(':{}'.format(k) if k else '')
attrs[attr] = _unicode(v)
continue
if not isinstance(iv, _unicode):
@@ -457,6 +459,7 @@
pass
return value
+
if __name__ == '__main__': # pragma: no cover
import sys
import marshal
@@ -470,7 +473,6 @@
(item_depth,) = sys.argv[1:]
item_depth = int(item_depth)
-
def handle_item(path, item):
marshal.dump((path, item), stdout)
return True