Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
3f07ec3d
Commit
3f07ec3d
authored
Mar 06, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixup JSON error reporting in previous commits.
parent
a4d01b08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
lib/ansible/utils/__init__.py
+9
-3
No files found.
lib/ansible/utils/__init__.py
View file @
3f07ec3d
...
...
@@ -351,13 +351,19 @@ def smush_ds(data):
else
:
return
data
def
parse_yaml
(
data
):
def
parse_yaml
(
data
,
path_hint
=
None
):
''' convert a yaml string to a data structure. Also supports JSON, ssssssh!!!'''
data
=
data
.
lstrip
()
if
data
.
startswith
(
"{"
)
or
data
.
startswith
(
"["
):
# since the line starts with { or [ we can infer this is a JSON document.
loaded
=
json
.
loads
(
data
)
try
:
loaded
=
json
.
loads
(
data
)
except
ValueError
,
ve
:
if
path_hint
:
raise
errors
.
AnsibleError
(
path_hint
+
": "
+
str
(
ve
))
else
:
raise
errors
.
AnsibleError
(
str
(
ve
))
else
:
# else this is pretty sure to be a YAML document
loaded
=
yaml
.
safe_load
(
data
)
...
...
@@ -522,7 +528,7 @@ def parse_yaml_from_file(path, vault_password=None):
data
=
vault
.
decrypt
(
data
)
try
:
return
parse_yaml
(
data
)
return
parse_yaml
(
data
,
path_hint
=
path
)
except
yaml
.
YAMLError
,
exc
:
process_yaml_error
(
exc
,
data
,
path
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment