mirror of https://github.com/borgbackup/borg.git
Merge pull request #7487 from ThomasWaldmann/pyupgrade-py39-plus
pyupgrade --py39-plus ./**/*.py
This commit is contained in:
commit
ffea8a0f25
|
@ -885,7 +885,7 @@ Duration: {0.duration}
|
||||||
item_size = item.size
|
item_size = item.size
|
||||||
if item_size != item_chunks_size:
|
if item_size != item_chunks_size:
|
||||||
raise BackupError(
|
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:
|
if has_damaged_chunks:
|
||||||
raise BackupError("File has damaged (all-zero) chunks. Try running borg check --repair.")
|
raise BackupError("File has damaged (all-zero) chunks. Try running borg check --repair.")
|
||||||
|
|
|
@ -244,7 +244,7 @@ class DebugMixIn:
|
||||||
if len(id) != 32: # 256bit
|
if len(id) != 32: # 256bit
|
||||||
raise ValueError("id must be 256bits or 64 hex digits")
|
raise ValueError("id must be 256bits or 64 hex digits")
|
||||||
except ValueError as err:
|
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
|
return EXIT_ERROR
|
||||||
try:
|
try:
|
||||||
data = repository.get(id)
|
data = repository.get(id)
|
||||||
|
@ -277,7 +277,7 @@ class DebugMixIn:
|
||||||
if len(id) != 32: # 256bit
|
if len(id) != 32: # 256bit
|
||||||
raise ValueError("id must be 256bits or 64 hex digits")
|
raise ValueError("id must be 256bits or 64 hex digits")
|
||||||
except ValueError as err:
|
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
|
return EXIT_ERROR
|
||||||
|
|
||||||
with open(args.object_path, "rb") as f:
|
with open(args.object_path, "rb") as f:
|
||||||
|
@ -305,13 +305,13 @@ class DebugMixIn:
|
||||||
if len(id) != 32: # 256bit
|
if len(id) != 32: # 256bit
|
||||||
raise ValueError("id must be 256bits or 64 hex digits")
|
raise ValueError("id must be 256bits or 64 hex digits")
|
||||||
except ValueError as err:
|
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
|
return EXIT_ERROR
|
||||||
|
|
||||||
with open(args.binary_path, "rb") as f:
|
with open(args.binary_path, "rb") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
|
||||||
with open(args.json_path, "r") as f:
|
with open(args.json_path) as f:
|
||||||
meta = json.load(f)
|
meta = json.load(f)
|
||||||
|
|
||||||
repo_objs = manifest.repo_objs
|
repo_objs = manifest.repo_objs
|
||||||
|
@ -332,7 +332,7 @@ class DebugMixIn:
|
||||||
if len(id) != 32: # 256bit
|
if len(id) != 32: # 256bit
|
||||||
raise ValueError("id must be 256bits or 64 hex digits")
|
raise ValueError("id must be 256bits or 64 hex digits")
|
||||||
except ValueError as err:
|
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
|
return EXIT_ERROR
|
||||||
repository.put(id, data)
|
repository.put(id, data)
|
||||||
print("object %s put." % hex_id)
|
print("object %s put." % hex_id)
|
||||||
|
|
|
@ -156,9 +156,7 @@ class PruneMixIn:
|
||||||
rule=kept_because[archive.id][0], num=kept_because[archive.id][1]
|
rule=kept_because[archive.id][0], num=kept_because[archive.id][1]
|
||||||
)
|
)
|
||||||
if args.output_list:
|
if args.output_list:
|
||||||
list_logger.info(
|
list_logger.info(f"{log_message:<40} {format_archive(archive)}")
|
||||||
"{message:<40} {archive}".format(message=log_message, archive=format_archive(archive))
|
|
||||||
)
|
|
||||||
pi.finish()
|
pi.finish()
|
||||||
if sig_int:
|
if sig_int:
|
||||||
# Ctrl-C / SIGINT: do not checkpoint (commit) again, we already have a checkpoint in this case.
|
# 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 ...
|
# if there is very little space, just show ...
|
||||||
return "..." + " " * (space - ellipsis_width)
|
return "..." + " " * (space - ellipsis_width)
|
||||||
if space < ellipsis_width + msg_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)
|
return msg + " " * (space - msg_width)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class Passphrase(str):
|
||||||
# passcommand is a system command (not inside pyinstaller env)
|
# passcommand is a system command (not inside pyinstaller env)
|
||||||
env = prepare_subprocess_env(system=True)
|
env = prepare_subprocess_env(system=True)
|
||||||
try:
|
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:
|
except (subprocess.CalledProcessError, FileNotFoundError) as e:
|
||||||
raise PasscommandFailure(e)
|
raise PasscommandFailure(e)
|
||||||
return cls(passphrase.rstrip("\n"))
|
return cls(passphrase.rstrip("\n"))
|
||||||
|
|
|
@ -5,7 +5,7 @@ import re
|
||||||
from collections import abc, namedtuple
|
from collections import abc, namedtuple
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from typing import Sequence, FrozenSet
|
from collections.abc import Sequence
|
||||||
|
|
||||||
from .logger import create_logger
|
from .logger import create_logger
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class Manifest:
|
||||||
|
|
||||||
NO_OPERATION_CHECK: Sequence[Operation] = tuple()
|
NO_OPERATION_CHECK: Sequence[Operation] = tuple()
|
||||||
|
|
||||||
SUPPORTED_REPO_FEATURES: FrozenSet[str] = frozenset([])
|
SUPPORTED_REPO_FEATURES: frozenset[str] = frozenset([])
|
||||||
|
|
||||||
MANIFEST_ID = b"\0" * 32
|
MANIFEST_ID = b"\0" * 32
|
||||||
|
|
||||||
|
|
|
@ -1693,7 +1693,7 @@ class LoggedIO:
|
||||||
size, tag, key, data = self._read(fd, header, segment, offset, (TAG_PUT2, TAG_PUT), read_data=read_data)
|
size, tag, key, data = self._read(fd, header, segment, offset, (TAG_PUT2, TAG_PUT), read_data=read_data)
|
||||||
if id != key:
|
if id != key:
|
||||||
raise IntegrityError(
|
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)
|
data_size_from_header = size - header_size(tag)
|
||||||
if expected_size is not None and expected_size != data_size_from_header:
|
if expected_size is not None and expected_size != data_size_from_header:
|
||||||
|
|
Loading…
Reference in New Issue