MCPcopy
hub / github.com/borgbackup/borg / _replace_placeholders

Function _replace_placeholders

src/borg/helpers/parseformat.py:363–384  ·  view source on GitHub ↗

Replace placeholders in text with their values.

(text, overrides={})

Source from the content-addressed store, hash-verified

361
362
363def _replace_placeholders(text, overrides={}):
364 """Replace placeholders in text with their values."""
365 from ..platform import fqdn, hostname, getosusername
366
367 current_time = datetime.now(timezone.utc)
368 data = {
369 "pid": os.getpid(),
370 "fqdn": fqdn,
371 "reverse-fqdn": ".".join(reversed(fqdn.split("."))),
372 "hostname": hostname,
373 "now": DatetimeWrapper(current_time.astimezone()),
374 "utcnow": DatetimeWrapper(current_time),
375 "unixtime": int(current_time.timestamp()),
376 "user": getosusername(),
377 "uuid4": str(uuid.uuid4()),
378 "borgversion": borg_version,
379 "borgmajor": "%d" % borg_version_tuple[:1],
380 "borgminor": "%d.%d" % borg_version_tuple[:2],
381 "borgpatch": "%d.%d.%d" % borg_version_tuple[:3],
382 **overrides,
383 }
384 return format_line(text, data)
385
386
387class PlaceholderReplacer:

Callers 1

__call__Method · 0.85

Calls 2

DatetimeWrapperClass · 0.85
format_lineFunction · 0.85

Tested by

no test coverage detected