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
bdef7f17
Commit
bdef7f17
authored
Aug 01, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3711 from ashorin/devel
Allow --diff on UTF-8 encoded files and templates
parents
44d06062
664215eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
lib/ansible/utils/__init__.py
+9
-2
No files found.
lib/ansible/utils/__init__.py
View file @
bdef7f17
...
@@ -706,6 +706,13 @@ def make_sudo_cmd(sudo_user, executable, cmd):
...
@@ -706,6 +706,13 @@ def make_sudo_cmd(sudo_user, executable, cmd):
prompt
,
sudo_user
,
executable
or
'$SHELL'
,
pipes
.
quote
(
cmd
))
prompt
,
sudo_user
,
executable
or
'$SHELL'
,
pipes
.
quote
(
cmd
))
return
(
'/bin/sh -c '
+
pipes
.
quote
(
sudocmd
),
prompt
)
return
(
'/bin/sh -c '
+
pipes
.
quote
(
sudocmd
),
prompt
)
_TO_UNICODE_TYPES
=
(
unicode
,
type
(
None
))
def
to_unicode
(
value
):
if
isinstance
(
value
,
_TO_UNICODE_TYPES
):
return
value
return
value
.
decode
(
"utf-8"
)
def
get_diff
(
diff
):
def
get_diff
(
diff
):
# called by --diff usage in playbook and runner via callbacks
# called by --diff usage in playbook and runner via callbacks
# include names in diffs 'before' and 'after' and do diff -U 10
# include names in diffs 'before' and 'after' and do diff -U 10
...
@@ -731,10 +738,10 @@ def get_diff(diff):
...
@@ -731,10 +738,10 @@ def get_diff(diff):
after_header
=
"after:
%
s"
%
diff
[
'after_header'
]
after_header
=
"after:
%
s"
%
diff
[
'after_header'
]
else
:
else
:
after_header
=
'after'
after_header
=
'after'
differ
=
difflib
.
unified_diff
(
diff
[
'before'
]
.
splitlines
(
True
),
diff
[
'after'
]
.
splitlines
(
True
),
before_header
,
after_header
,
''
,
''
,
10
)
differ
=
difflib
.
unified_diff
(
to_unicode
(
diff
[
'before'
])
.
splitlines
(
True
),
to_unicode
(
diff
[
'after'
])
.
splitlines
(
True
),
before_header
,
after_header
,
''
,
''
,
10
)
for
line
in
list
(
differ
):
for
line
in
list
(
differ
):
ret
.
append
(
line
)
ret
.
append
(
line
)
return
""
.
join
(
ret
)
return
u
""
.
join
(
ret
)
except
UnicodeDecodeError
:
except
UnicodeDecodeError
:
return
">> the files are different, but the diff library cannot compare unicode strings"
return
">> the files are different, but the diff library cannot compare unicode strings"
...
...
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