mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] simplify code
This commit is contained in:
parent
b7e946517b
commit
3155def9dd
1 changed files with 15 additions and 15 deletions
|
@ -654,25 +654,25 @@ def _get_files_diff(orig_file, new_file, as_string=False, skip_header=True):
|
||||||
header can also be removed if skip_header is True.
|
header can also be removed if skip_header is True.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
contents = [[], []]
|
with open(orig_file, 'r') as orig_file:
|
||||||
for i, path in enumerate((orig_file, new_file)):
|
orig_file = orig_file.readlines()
|
||||||
try:
|
|
||||||
with open(path, 'r') as f:
|
with open(new_file, 'r') as new_file:
|
||||||
contents[i] = f.readlines()
|
new_file.readlines()
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Compare files and format output
|
# Compare files and format output
|
||||||
diff = unified_diff(contents[0], contents[1])
|
diff = unified_diff(orig_file, new_file)
|
||||||
|
|
||||||
if skip_header:
|
if skip_header:
|
||||||
for i in range(2):
|
try:
|
||||||
try:
|
next(diff)
|
||||||
next(diff)
|
next(diff)
|
||||||
except:
|
except:
|
||||||
break
|
pass
|
||||||
|
|
||||||
if as_string:
|
if as_string:
|
||||||
result = ''.join(line for line in diff)
|
return ''.join(diff).rstrip()
|
||||||
return result.rstrip()
|
|
||||||
return diff
|
return diff
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue