Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/variables.py @ 706:59a3fb7fcac3
Prohibit "," and "|" in filter names
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Tue, 15 Aug 2023 10:38:38 +0200 |
| parents | 3a9d661d33b5 |
| children |
comparison
equal
deleted
inserted
replaced
| 705:0485a033c95d | 706:59a3fb7fcac3 |
|---|---|
| 130 """Filter registry""" | 130 """Filter registry""" |
| 131 | 131 |
| 132 | 132 |
| 133 def add_filter(name, fn): | 133 def add_filter(name, fn): |
| 134 """Register a variable filter function with name `name` and | 134 """Register a variable filter function with name `name` and |
| 135 implementation `fn` | 135 implementation `fn`. |
| 136 | 136 |
| 137 """ | 137 `name` may *not* contain ``,`` and ``|`` characters. |
| 138 | |
| 139 :raises ValueError: If an invalid `name` is given | |
| 140 | |
| 141 """ | |
| 142 if ('|' in name) or (',' in name): | |
| 143 raise ValueError("invalid filter name: %s" % (name, )) | |
| 138 _filter_registry[_normalized(name)] = fn | 144 _filter_registry[_normalized(name)] = fn |
| 139 | 145 |
| 140 | 146 |
| 141 def lookup_filter(name): | 147 def lookup_filter(name): |
| 142 """Lookup a variable filter with name `name` and return it's | 148 """Lookup a variable filter with name `name` and return it's |
