From ef4ce2ecb41e3244102b3c3f548418a560a9716e Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Mon, 25 Nov 2019 22:28:04 +0100 Subject: [PATCH] utils.strip_root --- restic_volume_backup/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/restic_volume_backup/utils.py b/restic_volume_backup/utils.py index cee752d..d3314cc 100644 --- a/restic_volume_backup/utils.py +++ b/restic_volume_backup/utils.py @@ -24,3 +24,15 @@ def is_true(value): Evaluates the truthfullness of a bool value in container labels """ return value in TRUE_VALUES + + +def strip_root(path): + """ + Removes the root slash in a path. + Example: /srv/data becomes srv/data + """ + path = path.strip() + if path.startswith('/'): + return path[1:] + + return path