From 6a633e4b6bbb4ce0e1d984da73bbb4004798559b Mon Sep 17 00:00:00 2001 From: Abhijeet Sharma Date: Tue, 25 Feb 2025 09:29:48 +0100 Subject: [PATCH 1/2] backport from PR 8522 --- src/borg/helpers/parseformat.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index a0fcdd9b95..bdfd012338 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -212,18 +212,19 @@ def replace_placeholders(text, overrides={}): from ..platform import fqdn, hostname, getosusername current_time = datetime.now(timezone.utc) data = { - 'pid': os.getpid(), - 'fqdn': fqdn, - 'reverse-fqdn': '.'.join(reversed(fqdn.split('.'))), - 'hostname': hostname, - 'now': DatetimeWrapper(current_time.astimezone(None)), - 'utcnow': DatetimeWrapper(current_time), - 'user': getosusername(), - 'uuid4': str(uuid.uuid4()), - 'borgversion': borg_version, - 'borgmajor': '%d' % borg_version_tuple[:1], - 'borgminor': '%d.%d' % borg_version_tuple[:2], - 'borgpatch': '%d.%d.%d' % borg_version_tuple[:3], + "pid": os.getpid(), + "fqdn": fqdn, + "reverse-fqdn": ".".join(reversed(fqdn.split("."))), + "hostname": hostname, + "now": DatetimeWrapper(current_time.astimezone()), + "utcnow": DatetimeWrapper(current_time), + "unixtime": int(current_time.timestamp()), + "user": getosusername(), + "uuid4": str(uuid.uuid4()), + "borgversion": borg_version, + "borgmajor": "%d" % borg_version_tuple[:1], + "borgminor": "%d.%d" % borg_version_tuple[:2], + "borgpatch": "%d.%d.%d" % borg_version_tuple[:3], **overrides, } return format_line(text, data) From b8fe9bc29eca426995aff680f23ca17050dc6903 Mon Sep 17 00:00:00 2001 From: Abhijeet Sharma Date: Wed, 26 Feb 2025 12:54:39 +0100 Subject: [PATCH 2/2] Removed black code style --- src/borg/helpers/parseformat.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index bdfd012338..d451dee673 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -212,19 +212,19 @@ def replace_placeholders(text, overrides={}): from ..platform import fqdn, hostname, getosusername current_time = datetime.now(timezone.utc) data = { - "pid": os.getpid(), - "fqdn": fqdn, - "reverse-fqdn": ".".join(reversed(fqdn.split("."))), - "hostname": hostname, - "now": DatetimeWrapper(current_time.astimezone()), - "utcnow": DatetimeWrapper(current_time), - "unixtime": int(current_time.timestamp()), - "user": getosusername(), - "uuid4": str(uuid.uuid4()), - "borgversion": borg_version, - "borgmajor": "%d" % borg_version_tuple[:1], - "borgminor": "%d.%d" % borg_version_tuple[:2], - "borgpatch": "%d.%d.%d" % borg_version_tuple[:3], + 'pid': os.getpid(), + 'fqdn': fqdn, + 'reverse-fqdn': '.'.join(reversed(fqdn.split('.'))), + 'hostname': hostname, + 'now': DatetimeWrapper(current_time.astimezone(None)), + 'utcnow': DatetimeWrapper(current_time), + 'unixtime': int(current_time.timestamp()), + 'user': getosusername(), + 'uuid4': str(uuid.uuid4()), + 'borgversion': borg_version, + 'borgmajor': '%d' % borg_version_tuple[:1], + 'borgminor': '%d.%d' % borg_version_tuple[:2], + 'borgpatch': '%d.%d.%d' % borg_version_tuple[:3], **overrides, } return format_line(text, data)