Format a default value for display using spec notation (__zero__, etc.).
(value, valueType, geompropNames)
| 308 | return None, False |
| 309 | |
| 310 | def formatDefaultValue(value, valueType, geompropNames): |
| 311 | '''Format a default value for display using spec notation (__zero__, etc.).''' |
| 312 | if value is None: |
| 313 | return 'None' |
| 314 | |
| 315 | # Handle string values (geomprops, empty strings, etc.) |
| 316 | if isinstance(value, str): |
| 317 | if value in geompropNames: |
| 318 | return f'_{value}_' |
| 319 | return '__empty__' if value == '' else value |
| 320 | |
| 321 | # Check if value matches a standard constant (__zero__, __one__, __half__) |
| 322 | for placeholder, display in [('0', '__zero__'), ('1', '__one__'), ('0.5', '__half__')]: |
| 323 | expansion = expandDefaultPlaceholder(placeholder, valueType) |
| 324 | if expansion is None: |
| 325 | continue |
| 326 | try: |
| 327 | if value == mx.createValueFromStrings(expansion, valueType): |
| 328 | return display |
| 329 | except Exception: |
| 330 | pass |
| 331 | |
| 332 | # Fall back to string representation |
| 333 | return str(value) |
| 334 | |
| 335 | |
| 336 | # ----------------------------------------------------------------------------- |
no test coverage detected