Re-use always_iterable
This commit is contained in:
parent
c2ce282a51
commit
5f86e5a1d6
1
setup.py
1
setup.py
|
@ -34,6 +34,7 @@ setup_params = dict(
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'six',
|
'six',
|
||||||
'xmltodict',
|
'xmltodict',
|
||||||
|
'jaraco.itertools>=2.0',
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,6 +3,7 @@ import itertools
|
||||||
from six.moves import urllib, map
|
from six.moves import urllib, map
|
||||||
|
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
from jaraco.itertools import always_iterable
|
||||||
|
|
||||||
from . import compat
|
from . import compat
|
||||||
|
|
||||||
|
@ -77,9 +78,7 @@ class Document(dict):
|
||||||
Load instances from the xmltodict result. Always return
|
Load instances from the xmltodict result. Always return
|
||||||
an iterable, even if the result is a singleton.
|
an iterable, even if the result is a singleton.
|
||||||
"""
|
"""
|
||||||
if type(doc) != list:
|
return map(cls, always_iterable(doc))
|
||||||
doc = [doc]
|
|
||||||
return map(cls, doc)
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
type = self._attr_types.get(name, lambda x: x)
|
type = self._attr_types.get(name, lambda x: x)
|
||||||
|
@ -193,11 +192,11 @@ class Result(ErrorHandler, Document):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def assumptions(self):
|
def assumptions(self):
|
||||||
return Assumption.from_doc(self.get('assumptions', []))
|
return Assumption.from_doc(self.get('assumptions'))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def warnings(self):
|
def warnings(self):
|
||||||
return Warning.from_doc(self.get('warnings', []))
|
return Warning.from_doc(self.get('warnings'))
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self.info
|
return self.info
|
||||||
|
|
Loading…
Reference in New Issue
Block a user