tools/traffic_annotation/scripts/extractor.py
def _parse_body(self, body: str):
    """Tokenizes and parses the arguments given to the definition function."""
    # Don't bother parsing CreateMutableNetworkTrafficAnnotationTag(), we don't
    # care about its arguments anyways.
    if self.type_name == AnnotationType.MUTABLE:
      return

    tokenizer = Tokenizer(body, self.file_path, self.line_number)

    # unique_id
    self.unique_id = self._parse_string(tokenizer)
    tokenizer.advance('comma')

    # extra_id (Partial/BranchedCompleting)
    if self.type_name in [
        AnnotationType.PARTIAL, AnnotationType.BRANCHED_COMPLETING
    ]:
      self.extra_id = self._parse_string(tokenizer)
      tokenizer.advance('comma')

    # partial_annotation (Completing/BranchedCompleting)
    if self.type_name in [
        AnnotationType.COMPLETING, AnnotationType.BRANCHED_COMPLETING
    ]:
      # Skip the |partial_annotation| argument. It can be a variable_name, or a
      # FunctionName(), so skip the parentheses if they're there.
      tokenizer.advance('symbol')
      if tokenizer.maybe_advance('left_paren'):
        tokenizer.advance('right_paren')
      tokenizer.advance('comma')

    # proto text
    self.text = self._parse_string(tokenizer)

    # The function call should end here without any more arguments.
    assert tokenizer.advance('right_paren')
Tokenizes and parses the arguments given to the definition function.
Tokenizes and parses the arguments given to the definition function.
Tokenizes and parses the arguments given to the definition function .
def _parse_body(self, body: str):
    if self.type_name == AnnotationType.MUTABLE:
      return
    tokenizer = Tokenizer(body, self.file_path, self.line_number)
    self.unique_id = self._parse_string(tokenizer)
    tokenizer.advance('comma')
    if self.type_name in [
        AnnotationType.PARTIAL, AnnotationType.BRANCHED_COMPLETING
    ]:
      self.extra_id = self._parse_string(tokenizer)
      tokenizer.advance('comma')
    if self.type_name in [
        AnnotationType.COMPLETING, AnnotationType.BRANCHED_COMPLETING
    ]:
      tokenizer.advance('symbol')
      if tokenizer.maybe_advance('left_paren'):
        tokenizer.advance('right_paren')
      tokenizer.advance('comma')
    self.text = self._parse_string(tokenizer)
    assert tokenizer.advance('right_paren')
def _parse_body ( self , body : str ) : if self . type_name == AnnotationType . MUTABLE : return tokenizer = Tokenizer ( body , self . file_path , self . line_number ) self . unique_id = self . _parse_string ( tokenizer ) tokenizer . advance ( 'comma' ) if self . type_name in [ AnnotationType . PARTIAL , AnnotationType . BRANCHED_COMPLETING ] : self . extra_id = self . _parse_string ( tokenizer ) tokenizer . advance ( 'comma' ) if self . type_name in [ AnnotationType . COMPLETING , AnnotationType . BRANCHED_COMPLETING ] : tokenizer . advance ( 'symbol' ) if tokenizer . maybe_advance ( 'left_paren' ) : tokenizer . advance ( 'right_paren' ) tokenizer . advance ( 'comma' ) self . text = self . _parse_string ( tokenizer ) assert tokenizer . advance ( 'right_paren' )
Tokenizes and parses the arguments given to the definition function.
Tokenizes and parses the arguments given to the definition function .
"""Tokenizes and parses the arguments given to the definition function.""" # Don't bother parsing CreateMutableNetworkTrafficAnnotationTag(), we don't # care about its arguments anyways. # unique_id # extra_id (Partial/BranchedCompleting) # partial_annotation (Completing/BranchedCompleting) # Skip the |partial_annotation| argument. It can be a variable_name, or a # FunctionName(), so skip the parentheses if they're there. # proto text # The function call should end here without any more arguments.
self
body
str