Prepare release 1.0.4

This commit is contained in:
Cristi Vîjdea
2017-12-16 18:18:21 +01:00
committed by GitHub
parent 73bd7a136d
commit a2c21539f7
8 changed files with 71 additions and 24 deletions
+5
View File
@@ -101,6 +101,10 @@ class OpenAPICodecJson(_OpenAPICodec):
class SaneYamlDumper(yaml.SafeDumper):
"""YamlDumper class usable for dumping ``OrderedDict`` and list instances in a standard way."""
def ignore_aliases(self, data):
"""Disable YAML references."""
return True
def increase_indent(self, flow=False, indentless=False, **kwargs):
"""https://stackoverflow.com/a/39681672
@@ -152,6 +156,7 @@ def yaml_sane_dump(data, binary):
* OrderedDicts are dumped as regular mappings instead of non-standard !!odict
* multi-line mapping style instead of json-like inline style
* list elements are indented into their parents
* YAML references/aliases are disabled
:param dict data: the data to be serializers
:param bool binary: True to return a utf-8 encoded binary object, False to return a string
+8 -4
View File
@@ -115,15 +115,19 @@ class SwaggerDict(OrderedDict):
setattr(self, attr, val)
@staticmethod
def _as_odict(obj):
def _as_odict(obj, memo):
"""Implementation detail of :meth:`.as_odict`"""
if id(obj) in memo:
return memo[id(obj)]
if isinstance(obj, dict):
result = OrderedDict()
memo[id(obj)] = result
for attr, val in obj.items():
result[attr] = SwaggerDict._as_odict(val)
result[attr] = SwaggerDict._as_odict(val, memo)
return result
elif isinstance(obj, (list, tuple)):
return type(obj)(SwaggerDict._as_odict(elem) for elem in obj)
return type(obj)(SwaggerDict._as_odict(elem, memo) for elem in obj)
return obj
@@ -132,7 +136,7 @@ class SwaggerDict(OrderedDict):
:rtype: OrderedDict
"""
return SwaggerDict._as_odict(self)
return SwaggerDict._as_odict(self, {})
def __reduce__(self):
# for pickle supprt; this skips calls to all SwaggerDict __init__ methods and relies