Peter Pentchev | b91fc93 | 2023-01-19 15:27:13 +0200 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: StorPool <support@storpool.com> |
2 | # SPDX-License-Identifier: BSD-2-Clause | ||||
3 | """Common utilities for the gifn-apply modules.""" | ||||
4 | |||||
5 | |||||
6 | # This will go away with Python 3.9's str.removeprefix(). | ||||
7 | def str_removeprefix(value: str, prefix: str) -> str: | ||||
8 | """Return the value with the prefix stripped if it was there, otherwise unchanged.""" | ||||
9 | if not value.startswith(prefix): | ||||
10 | return value | ||||
11 | |||||
12 | return value[len(prefix) :] |