Replace placeholders in text with their values.
(text, overrides={})
| 361 | |
| 362 | |
| 363 | def _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 | |
| 387 | class PlaceholderReplacer: |
no test coverage detected