Beispiel #1
0
 def _extract_tag(self):
     """Extracts `TextValue` of tag from the current event."""
     value = getattr(self._event, 'tag', None)
     if value is None or value == '!':
         return None
     tag = TextValue(value)
     tag.span = self._extract_property_span(self._event.start_mark, '!')
     return tag
Beispiel #2
0
 def _extract_anchor(self):
     """Extracts `TextValue` of anchor from the current event."""
     value = getattr(self._event, 'anchor', None)
     if value is None or value in ['*', '&']:
         return None
     anchor = TextValue(value)
     symbol = '&'
     if isinstance(self._event, pyyaml.AliasEvent):
         symbol = '*'
     anchor.span = self._extract_property_span(self._event.start_mark, symbol)
     return anchor
Beispiel #3
0
 def _create_record_key(self):
     """Creates `TextValue` of record key."""
     # check if key is scalar
     if not isinstance(self._event, pyyaml.ScalarEvent):
         start_pos = Position.from_mark(self._event.start_mark)
         self._create_fatal_error_node(start_pos)
         notification = Notification.from_name('ComplexRecordKey')
         notification.span = self._fatal_error_node.span
         self.notification_handler.report(notification)
         self._event = None
         self._iterate_events = False
         return None
     key = TextValue()
     key.value = self._event.value
     key.span = Span.from_event(self._event)
     return key