MCPcopy Create free account
hub / github.com/STIXProject/python-stix / _unset_default

Function _unset_default

stix/common/structured_text.py:88–105  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

86
87@contextlib.contextmanager
88def _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
108class StructuredTextList(stix.TypedCollection, collections.Sequence):

Callers 2

to_objMethod · 0.85
to_listMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected