mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
Merge pull request #1422 from wwitzel3/release_3.3.0
Remove unused code, OrderedDictLoader
This commit is contained in:
commit
ab311d5c2f
@ -1,7 +1,6 @@
|
||||
# Python
|
||||
from collections import OrderedDict
|
||||
import json
|
||||
import yaml
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
@ -13,36 +12,6 @@ from rest_framework import parsers
|
||||
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):
|
||||
"""
|
||||
Parses JSON-serialized data, preserving order of dictionary keys.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user