mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 22:49:32 -02:30
Merge pull request #1422 from wwitzel3/release_3.3.0
Remove unused code, OrderedDictLoader
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
# Python
|
# Python
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import json
|
import json
|
||||||
import yaml
|
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -13,36 +12,6 @@ from rest_framework import parsers
|
|||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
|
|
||||||
|
|
||||||
class OrderedDictLoader(yaml.SafeLoader):
|
|
||||||
"""
|
|
||||||
This yaml loader is used to deal with current pyYAML (3.12) not supporting
|
|
||||||
custom object pairs hook. Remove it when new version adds that support.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def construct_mapping(self, node, deep=False):
|
|
||||||
if isinstance(node, yaml.nodes.MappingNode):
|
|
||||||
self.flatten_mapping(node)
|
|
||||||
else:
|
|
||||||
raise yaml.constructor.ConstructorError(
|
|
||||||
None, None,
|
|
||||||
"expected a mapping node, but found %s" % node.id,
|
|
||||||
node.start_mark
|
|
||||||
)
|
|
||||||
mapping = OrderedDict()
|
|
||||||
for key_node, value_node in node.value:
|
|
||||||
key = self.construct_object(key_node, deep=deep)
|
|
||||||
try:
|
|
||||||
hash(key)
|
|
||||||
except TypeError as exc:
|
|
||||||
raise yaml.constructor.ConstructorError(
|
|
||||||
"while constructing a mapping", node.start_mark,
|
|
||||||
"found unacceptable key (%s)" % exc, key_node.start_mark
|
|
||||||
)
|
|
||||||
value = self.construct_object(value_node, deep=deep)
|
|
||||||
mapping[key] = value
|
|
||||||
return mapping
|
|
||||||
|
|
||||||
|
|
||||||
class JSONParser(parsers.JSONParser):
|
class JSONParser(parsers.JSONParser):
|
||||||
"""
|
"""
|
||||||
Parses JSON-serialized data, preserving order of dictionary keys.
|
Parses JSON-serialized data, preserving order of dictionary keys.
|
||||||
|
|||||||
Reference in New Issue
Block a user