summaryrefslogtreecommitdiff
path: root/lib/ansible/cli
diff options
context:
space:
mode:
authorDavid Shrewsbury <Shrews@users.noreply.github.com>2020-11-23 13:32:03 -0500
committerGitHub <noreply@github.com>2020-11-23 13:32:03 -0500
commit0fa1cd88ce57167292803e9257fe2ed50cb3e1e0 (patch)
treea7f92b4e3d2d765c68ddf98dc032a134ed0c9f32 /lib/ansible/cli
parenta57539f764d28ffbd71be86db759e16edaf3b649 (diff)
downloadansible-0fa1cd88ce57167292803e9257fe2ed50cb3e1e0.tar.gz
ansible-doc: replace DataLoader with from_yaml (#72686)
* Replace DataLoader with pure yaml
Diffstat (limited to 'lib/ansible/cli')
-rw-r--r--lib/ansible/cli/doc.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py
index e1299a9032..b87868e312 100644
--- a/lib/ansible/cli/doc.py
+++ b/lib/ansible/cli/doc.py
@@ -22,13 +22,12 @@ from ansible import context
from ansible.cli import CLI
from ansible.cli.arguments import option_helpers as opt_help
from ansible.collections.list import list_collection_dirs
-from ansible.errors import AnsibleError, AnsibleOptionsError
+from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError
from ansible.module_utils._text import to_native, to_text
from ansible.module_utils.common._collections_compat import Container, Sequence
from ansible.module_utils.common.json import AnsibleJSONEncoder
from ansible.module_utils.compat import importlib
from ansible.module_utils.six import iteritems, string_types
-from ansible.parsing.dataloader import DataLoader
from ansible.parsing.plugin_docs import read_docstub
from ansible.parsing.utils.yaml import from_yaml
from ansible.parsing.yaml.dumper import AnsibleDumper
@@ -89,8 +88,11 @@ class RoleMixin(object):
else:
raise AnsibleError("A path is required to load argument specs for role '%s'" % role_name)
- loader = DataLoader()
- return loader.load_from_file(path, cache=False, unsafe=True)
+ try:
+ with open(path, 'r') as f:
+ return from_yaml(f.read(), file_name=path)
+ except (IOError, OSError) as e:
+ raise AnsibleParserError("An error occurred while trying to read the file '%s': %s" % (path, to_native(e)), orig_exc=e)
def _find_all_normal_roles(self, role_paths, name_filters=None):
"""Find all non-collection roles that have an argument spec file.