Source code for cuvis_ai.utils.dict

from typing import Any


[docs] def remove_prefix_str(s, prefix): if s.startswith(prefix): return s[len(prefix):] return s
[docs] def remove_prefix(d: dict[str, Any], prefix, keep_only=False): return {remove_prefix_str(k, prefix): v for k, v in d.items() if k.startswith(prefix) or not keep_only}
[docs] def add_prefix(d: dict[str, Any], prefix): return {prefix+k: v for k, v in d.items()}