mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Remove refactoring code
This commit is contained in:
parent
78f7c530bb
commit
13f11fddce
1 changed files with 7 additions and 7 deletions
|
@ -2458,10 +2458,10 @@ def append(path, *args, **kwargs):
|
|||
|
||||
# Make sure we have a newline at the end of the file. Do this in binary
|
||||
# mode so SEEK_END with nonzero offset will work.
|
||||
with salt.utils.fopen(path, 'rb+') as o_file:
|
||||
with salt.utils.fopen(path, 'rb+') as ofile:
|
||||
linesep = salt.utils.to_bytes(os.linesep)
|
||||
try:
|
||||
o_file.seek(-len(linesep), os.SEEK_END)
|
||||
ofile.seek(-len(linesep), os.SEEK_END)
|
||||
except IOError as exc:
|
||||
if exc.errno in (errno.EINVAL, errno.ESPIPE):
|
||||
# Empty file, simply append lines at the beginning of the file
|
||||
|
@ -2469,14 +2469,14 @@ def append(path, *args, **kwargs):
|
|||
else:
|
||||
raise
|
||||
else:
|
||||
if o_file.read(len(linesep)) != linesep:
|
||||
o_file.seek(0, os.SEEK_END)
|
||||
o_file.write(linesep)
|
||||
if ofile.read(len(linesep)) != linesep:
|
||||
ofile.seek(0, os.SEEK_END)
|
||||
ofile.write(linesep)
|
||||
|
||||
# Append lines in text mode
|
||||
with salt.utils.fopen(path, 'a') as o_file:
|
||||
with salt.utils.fopen(path, 'a') as ofile:
|
||||
for new_line in args:
|
||||
o_file.write('{0}{1}'.format(new_line, os.linesep))
|
||||
ofile.write('{0}{1}'.format(new_line, os.linesep))
|
||||
|
||||
return 'Wrote {0} lines to "{1}"'.format(len(args), path)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue