mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
Added function remove_prefix_from_keys in util
This commit is contained in:
parent
25a784fa2e
commit
a77a6e3c6f
@ -221,6 +221,13 @@ def remove_keys_with_prefix(dictionary: dict, prefix: tuple=('Previous/', 'Sourc
|
||||
"""
|
||||
return {key: value for key, value in dictionary.items() if not key.startswith(prefix)}
|
||||
|
||||
def remove_prefix_from_keys(dictionary: dict, prefix: str) -> dict:
|
||||
"""
|
||||
Removes the specified prefix from the keys of the dictionary.
|
||||
If a key starts with the prefix, it is removed.
|
||||
"""
|
||||
return {key[len(prefix):] if key.startswith(prefix) else key: value for key, value in dictionary.items()}
|
||||
|
||||
|
||||
def get_trans_table():
|
||||
return str.maketrans({
|
||||
|
Loading…
x
Reference in New Issue
Block a user