1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 01:37:20 +00:00

use dash_open

This commit is contained in:
Thomas Waldmann 2017-07-04 02:56:50 +02:00
parent a96dede632
commit e728d102ec

View file

@ -65,6 +65,7 @@
from .helpers import replace_placeholders
from .helpers import ChunkIteratorFileWrapper
from .helpers import popen_with_error_handling
from .helpers import dash_open
from .nanorst import rst_to_terminal
from .patterns import ArgparsePatternAction, ArgparseExcludeFileAction, ArgparsePatternFileAction, parse_exclude_pattern
from .patterns import PatternMatcher
@ -778,10 +779,8 @@ def do_export_tar(self, args, repository, manifest, key, archive):
else:
filter = args.tar_filter
if args.tarfile == '-':
tarstream, tarstream_close = sys.stdout.buffer, False
else:
tarstream, tarstream_close = open(args.tarfile, 'wb'), True
tarstream = dash_open(args.tarfile, 'wb')
tarstream_close = args.tarfile != '-'
if filter:
# When we put a filter between us and the final destination,
@ -1737,11 +1736,8 @@ def output(fd):
fd.write('\n')
fd.write(' ]\n}\n')
if args.path == '-':
output(sys.stdout)
else:
with open(args.path, 'w') as fd:
output(fd)
with dash_open(args.path, 'w') as fd:
output(fd)
return EXIT_SUCCESS
@with_repository(compatibility=Manifest.NO_OPERATION_CHECK)
@ -1752,11 +1748,8 @@ def do_debug_dump_manifest(self, args, repository, manifest, key):
meta = prepare_dump_dict(msgpack.fallback.unpackb(data, object_hook=StableDict, unicode_errors='surrogateescape'))
if args.path == '-':
json.dump(meta, sys.stdout, indent=4)
else:
with open(args.path, 'w') as fd:
json.dump(meta, fd, indent=4)
with dash_open(args.path, 'w') as fd:
json.dump(meta, fd, indent=4)
return EXIT_SUCCESS
@with_repository(compatibility=Manifest.NO_OPERATION_CHECK)