mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
pyupgrade --py39-plus ./**/*.py
This commit is contained in:
parent
dfef2b9092
commit
52793be923
7 changed files with 12 additions and 14 deletions
|
@ -885,7 +885,7 @@ def make_parent(path):
|
|||
item_size = item.size
|
||||
if item_size != item_chunks_size:
|
||||
raise BackupError(
|
||||
"Size inconsistency detected: size {}, chunks size {}".format(item_size, item_chunks_size)
|
||||
f"Size inconsistency detected: size {item_size}, chunks size {item_chunks_size}"
|
||||
)
|
||||
if has_damaged_chunks:
|
||||
raise BackupError("File has damaged (all-zero) chunks. Try running borg check --repair.")
|
||||
|
|
|
@ -244,7 +244,7 @@ def do_debug_get_obj(self, args, repository):
|
|||
if len(id) != 32: # 256bit
|
||||
raise ValueError("id must be 256bits or 64 hex digits")
|
||||
except ValueError as err:
|
||||
print("object id %s is invalid [%s]." % (hex_id, str(err)))
|
||||
print(f"object id {hex_id} is invalid [{str(err)}].")
|
||||
return EXIT_ERROR
|
||||
try:
|
||||
data = repository.get(id)
|
||||
|
@ -277,7 +277,7 @@ def do_debug_parse_obj(self, args, repository, manifest):
|
|||
if len(id) != 32: # 256bit
|
||||
raise ValueError("id must be 256bits or 64 hex digits")
|
||||
except ValueError as err:
|
||||
print("object id %s is invalid [%s]." % (hex_id, str(err)))
|
||||
print(f"object id {hex_id} is invalid [{str(err)}].")
|
||||
return EXIT_ERROR
|
||||
|
||||
with open(args.object_path, "rb") as f:
|
||||
|
@ -305,13 +305,13 @@ def do_debug_format_obj(self, args, repository, manifest):
|
|||
if len(id) != 32: # 256bit
|
||||
raise ValueError("id must be 256bits or 64 hex digits")
|
||||
except ValueError as err:
|
||||
print("object id %s is invalid [%s]." % (hex_id, str(err)))
|
||||
print(f"object id {hex_id} is invalid [{str(err)}].")
|
||||
return EXIT_ERROR
|
||||
|
||||
with open(args.binary_path, "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
with open(args.json_path, "r") as f:
|
||||
with open(args.json_path) as f:
|
||||
meta = json.load(f)
|
||||
|
||||
repo_objs = manifest.repo_objs
|
||||
|
@ -332,7 +332,7 @@ def do_debug_put_obj(self, args, repository):
|
|||
if len(id) != 32: # 256bit
|
||||
raise ValueError("id must be 256bits or 64 hex digits")
|
||||
except ValueError as err:
|
||||
print("object id %s is invalid [%s]." % (hex_id, str(err)))
|
||||
print(f"object id {hex_id} is invalid [{str(err)}].")
|
||||
return EXIT_ERROR
|
||||
repository.put(id, data)
|
||||
print("object %s put." % hex_id)
|
||||
|
|
|
@ -156,9 +156,7 @@ def checkpoint_func():
|
|||
rule=kept_because[archive.id][0], num=kept_because[archive.id][1]
|
||||
)
|
||||
if args.output_list:
|
||||
list_logger.info(
|
||||
"{message:<40} {archive}".format(message=log_message, archive=format_archive(archive))
|
||||
)
|
||||
list_logger.info(f"{log_message:<40} {format_archive(archive)}")
|
||||
pi.finish()
|
||||
if sig_int:
|
||||
# Ctrl-C / SIGINT: do not checkpoint (commit) again, we already have a checkpoint in this case.
|
||||
|
|
|
@ -1033,7 +1033,7 @@ def ellipsis_truncate(msg, space):
|
|||
# if there is very little space, just show ...
|
||||
return "..." + " " * (space - ellipsis_width)
|
||||
if space < ellipsis_width + msg_width:
|
||||
return "{}...{}".format(swidth_slice(msg, space // 2 - ellipsis_width), swidth_slice(msg, -space // 2))
|
||||
return f"{swidth_slice(msg, space // 2 - ellipsis_width)}...{swidth_slice(msg, -space // 2)}"
|
||||
return msg + " " * (space - msg_width)
|
||||
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ def env_passcommand(cls, default=None):
|
|||
# passcommand is a system command (not inside pyinstaller env)
|
||||
env = prepare_subprocess_env(system=True)
|
||||
try:
|
||||
passphrase = subprocess.check_output(shlex.split(passcommand), universal_newlines=True, env=env)
|
||||
passphrase = subprocess.check_output(shlex.split(passcommand), text=True, env=env)
|
||||
except (subprocess.CalledProcessError, FileNotFoundError) as e:
|
||||
raise PasscommandFailure(e)
|
||||
return cls(passphrase.rstrip("\n"))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
from collections import abc, namedtuple
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from operator import attrgetter
|
||||
from typing import Sequence, FrozenSet
|
||||
from collections.abc import Sequence
|
||||
|
||||
from .logger import create_logger
|
||||
|
||||
|
@ -211,7 +211,7 @@ class Operation(enum.Enum):
|
|||
|
||||
NO_OPERATION_CHECK: Sequence[Operation] = tuple()
|
||||
|
||||
SUPPORTED_REPO_FEATURES: FrozenSet[str] = frozenset([])
|
||||
SUPPORTED_REPO_FEATURES: frozenset[str] = frozenset([])
|
||||
|
||||
MANIFEST_ID = b"\0" * 32
|
||||
|
||||
|
|
|
@ -1693,7 +1693,7 @@ def read(self, segment, offset, id, *, read_data=True, expected_size=None):
|
|||
size, tag, key, data = self._read(fd, header, segment, offset, (TAG_PUT2, TAG_PUT), read_data=read_data)
|
||||
if id != key:
|
||||
raise IntegrityError(
|
||||
"Invalid segment entry header, is not for wanted id [segment {}, offset {}]".format(segment, offset)
|
||||
f"Invalid segment entry header, is not for wanted id [segment {segment}, offset {offset}]"
|
||||
)
|
||||
data_size_from_header = size - header_size(tag)
|
||||
if expected_size is not None and expected_size != data_size_from_header:
|
||||
|
|
Loading…
Reference in a new issue