Returns an inline safe string if the provided string is an identifier and raises an exception otherwise. Args: ident (str): The string supposed to contain an identifier. Returns: Script.String: An inline safe string Raises: PolygraphyException: if the inpu
(ident)
| 25 | |
| 26 | |
| 27 | def inline_identifier(ident): |
| 28 | """ |
| 29 | Returns an inline safe string if the provided string is an identifier and raises an exception otherwise. |
| 30 | |
| 31 | Args: |
| 32 | ident (str): The string supposed to contain an identifier. |
| 33 | |
| 34 | Returns: |
| 35 | Script.String: An inline safe string |
| 36 | |
| 37 | Raises: |
| 38 | PolygraphyException: if the input string is not an identifier. |
| 39 | """ |
| 40 | if not ident.isidentifier(): |
| 41 | G_LOGGER.critical( |
| 42 | f"This argument must be a valid identifier. Provided argument cannot be a Python identifier: {ident}" |
| 43 | ) |
| 44 | return inline(safe(ident)) |
| 45 | |
| 46 | |
| 47 | @mod.export() |
no test coverage detected