Unsets the ordinality of the StructuredText object `text` if the ordinality is equal to the DEFAULT_ORDINALITY. The ordinaity will be returned to its original state after exiting the context manager.
(text)
| 86 | |
| 87 | @contextlib.contextmanager |
| 88 | def _unset_default(text): |
| 89 | """Unsets the ordinality of the StructuredText object `text` if the |
| 90 | ordinality is equal to the DEFAULT_ORDINALITY. |
| 91 | |
| 92 | The ordinaity will be returned to its original state after exiting the |
| 93 | context manager. |
| 94 | |
| 95 | """ |
| 96 | ordinality = text.ordinality |
| 97 | |
| 98 | try: |
| 99 | if ordinality == DEFAULT_ORDINALITY: |
| 100 | text.ordinality = None # Unset |
| 101 | |
| 102 | yield # Return to caller |
| 103 | finally: |
| 104 | # Reset |
| 105 | text.ordinality = ordinality |
| 106 | |
| 107 | |
| 108 | class StructuredTextList(stix.TypedCollection, collections.Sequence): |