mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 09:47:58 +00:00
use dash_open
This commit is contained in:
parent
a96dede632
commit
e728d102ec
1 changed files with 7 additions and 14 deletions
|
@ -65,6 +65,7 @@
|
||||||
from .helpers import replace_placeholders
|
from .helpers import replace_placeholders
|
||||||
from .helpers import ChunkIteratorFileWrapper
|
from .helpers import ChunkIteratorFileWrapper
|
||||||
from .helpers import popen_with_error_handling
|
from .helpers import popen_with_error_handling
|
||||||
|
from .helpers import dash_open
|
||||||
from .nanorst import rst_to_terminal
|
from .nanorst import rst_to_terminal
|
||||||
from .patterns import ArgparsePatternAction, ArgparseExcludeFileAction, ArgparsePatternFileAction, parse_exclude_pattern
|
from .patterns import ArgparsePatternAction, ArgparseExcludeFileAction, ArgparsePatternFileAction, parse_exclude_pattern
|
||||||
from .patterns import PatternMatcher
|
from .patterns import PatternMatcher
|
||||||
|
@ -778,10 +779,8 @@ def do_export_tar(self, args, repository, manifest, key, archive):
|
||||||
else:
|
else:
|
||||||
filter = args.tar_filter
|
filter = args.tar_filter
|
||||||
|
|
||||||
if args.tarfile == '-':
|
tarstream = dash_open(args.tarfile, 'wb')
|
||||||
tarstream, tarstream_close = sys.stdout.buffer, False
|
tarstream_close = args.tarfile != '-'
|
||||||
else:
|
|
||||||
tarstream, tarstream_close = open(args.tarfile, 'wb'), True
|
|
||||||
|
|
||||||
if filter:
|
if filter:
|
||||||
# When we put a filter between us and the final destination,
|
# When we put a filter between us and the final destination,
|
||||||
|
@ -1737,11 +1736,8 @@ def output(fd):
|
||||||
fd.write('\n')
|
fd.write('\n')
|
||||||
fd.write(' ]\n}\n')
|
fd.write(' ]\n}\n')
|
||||||
|
|
||||||
if args.path == '-':
|
with dash_open(args.path, 'w') as fd:
|
||||||
output(sys.stdout)
|
output(fd)
|
||||||
else:
|
|
||||||
with open(args.path, 'w') as fd:
|
|
||||||
output(fd)
|
|
||||||
return EXIT_SUCCESS
|
return EXIT_SUCCESS
|
||||||
|
|
||||||
@with_repository(compatibility=Manifest.NO_OPERATION_CHECK)
|
@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'))
|
meta = prepare_dump_dict(msgpack.fallback.unpackb(data, object_hook=StableDict, unicode_errors='surrogateescape'))
|
||||||
|
|
||||||
if args.path == '-':
|
with dash_open(args.path, 'w') as fd:
|
||||||
json.dump(meta, sys.stdout, indent=4)
|
json.dump(meta, fd, indent=4)
|
||||||
else:
|
|
||||||
with open(args.path, 'w') as fd:
|
|
||||||
json.dump(meta, fd, indent=4)
|
|
||||||
return EXIT_SUCCESS
|
return EXIT_SUCCESS
|
||||||
|
|
||||||
@with_repository(compatibility=Manifest.NO_OPERATION_CHECK)
|
@with_repository(compatibility=Manifest.NO_OPERATION_CHECK)
|
||||||
|
|
Loading…
Reference in a new issue