convenience function to build a namespaced event tag string from joining with the TABPART character the base, prefix and suffix If string prefix is a valid key in TAGS Then use the value of key prefix Else use prefix string If suffix is a list Then join all string elements of
(suffix="", prefix="", base=SALT)
| 198 | |
| 199 | |
| 200 | def tagify(suffix="", prefix="", base=SALT): |
| 201 | """ |
| 202 | convenience function to build a namespaced event tag string |
| 203 | from joining with the TABPART character the base, prefix and suffix |
| 204 | |
| 205 | If string prefix is a valid key in TAGS Then use the value of key prefix |
| 206 | Else use prefix string |
| 207 | |
| 208 | If suffix is a list Then join all string elements of suffix individually |
| 209 | Else use string suffix |
| 210 | |
| 211 | """ |
| 212 | parts = [base, TAGS.get(prefix, prefix)] |
| 213 | if isinstance(suffix, Iterable) and not isinstance( |
| 214 | suffix, str |
| 215 | ): # list so extend parts |
| 216 | parts.extend(suffix) |
| 217 | else: # string so append |
| 218 | parts.append(suffix) |
| 219 | |
| 220 | str_parts = [] |
| 221 | for part in parts: |
| 222 | part_str = None |
| 223 | try: |
| 224 | part_str = salt.utils.stringutils.to_str(part) |
| 225 | except TypeError: |
| 226 | part_str = str(part) |
| 227 | if part_str: |
| 228 | str_parts.append(part_str) |
| 229 | return TAGPARTER.join(str_parts) |
| 230 | |
| 231 | |
| 232 | class SaltEvent: |
no test coverage detected