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
c692de6b
Commit
c692de6b
authored
Feb 09, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup YAML parse error warning code a tiny amount.
parent
5c382487
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
lib/ansible/utils/__init__.py
+16
-9
No files found.
lib/ansible/utils/__init__.py
View file @
c692de6b
...
...
@@ -236,15 +236,7 @@ def parse_yaml(data):
''' convert a yaml string to a data structure '''
return
yaml
.
load
(
data
)
def
parse_yaml_from_file
(
path
):
''' convert a yaml file to a data structure '''
try
:
data
=
file
(
path
)
.
read
()
return
parse_yaml
(
data
)
except
IOError
:
raise
errors
.
AnsibleError
(
"file not found:
%
s"
%
path
)
except
yaml
.
YAMLError
,
exc
:
def
process_yaml_error
(
exc
,
data
,
path
=
None
):
if
hasattr
(
exc
,
'problem_mark'
):
mark
=
exc
.
problem_mark
if
mark
.
line
-
1
>=
0
:
...
...
@@ -262,9 +254,24 @@ Note: The error may actually appear before this position: line %s, column %s
else
:
# No problem markers means we have to throw a generic
# "stuff messed up" type message. Sry bud.
if
path
:
msg
=
"Could not parse YAML. Check over
%
s again."
%
path
else
:
msg
=
"Could not parse YAML."
raise
errors
.
AnsibleYAMLValidationFailed
(
msg
)
def
parse_yaml_from_file
(
path
):
''' convert a yaml file to a data structure '''
try
:
data
=
file
(
path
)
.
read
()
return
parse_yaml
(
data
)
except
IOError
:
raise
errors
.
AnsibleError
(
"file not found:
%
s"
%
path
)
except
yaml
.
YAMLError
,
exc
:
process_yaml_error
(
exc
,
data
,
path
)
def
parse_kv
(
args
):
''' convert a string of key/value items to a dict '''
...
...
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