components/sync/PRESUBMIT.py
def ParseEntitySpecificsProtoFieldIdentifiers(input_api, proto_path):
  """Parses proto field identifiers from the EntitySpecifics definition.
  Args:
    input_api: presubmit_support InputAPI instance
    proto_path: path to the file containing the proto field definitions
  Returns:
    A dictionary of the format {'SyncDataType': 'field_identifier'}
    e.g. {'AutofillSpecifics': 'autofill'}
  """
  proto_field_definitions = {}
  proto_file_contents = input_api.ReadFile(proto_path).splitlines()
  start_pattern = input_api.re.compile(PROTO_DEFINITION_START_PATTERN)
  end_pattern = input_api.re.compile(PROTO_DEFINITION_END_PATTERN)
  in_proto_def = False
  for line in proto_file_contents:
    if start_pattern.match(line):
      in_proto_def = True
      continue
    if in_proto_def:
      if end_pattern.match(line):
        break
      line = line.strip()
      split_proto_line = line.split(' ')
      # ignore comments and lines that don't contain definitions.
      if '//' in line or len(split_proto_line) < 3:
        continue

      field_typename = split_proto_line[0]
      field_identifier = split_proto_line[1]
      proto_field_definitions[field_typename] = field_identifier
  return proto_field_definitions
Parses proto field identifiers from the EntitySpecifics definition.
  Args:
    input_api: presubmit_support InputAPI instance
    proto_path: path to the file containing the proto field definitions
  Returns:
    A dictionary of the format {'SyncDataType': 'field_identifier'}
    e.g. {'AutofillSpecifics': 'autofill'}
  
Parses proto field identifiers from the EntitySpecifics definition.
Parses proto field identifiers from the EntitySpecifics definition .
def ParseEntitySpecificsProtoFieldIdentifiers(input_api, proto_path):
  proto_field_definitions = {}
  proto_file_contents = input_api.ReadFile(proto_path).splitlines()
  start_pattern = input_api.re.compile(PROTO_DEFINITION_START_PATTERN)
  end_pattern = input_api.re.compile(PROTO_DEFINITION_END_PATTERN)
  in_proto_def = False
  for line in proto_file_contents:
    if start_pattern.match(line):
      in_proto_def = True
      continue
    if in_proto_def:
      if end_pattern.match(line):
        break
      line = line.strip()
      split_proto_line = line.split(' ')
      if '//' in line or len(split_proto_line) < 3:
        continue
      field_typename = split_proto_line[0]
      field_identifier = split_proto_line[1]
      proto_field_definitions[field_typename] = field_identifier
  return proto_field_definitions
def ParseEntitySpecificsProtoFieldIdentifiers ( input_api , proto_path ) : proto_field_definitions = { } proto_file_contents = input_api . ReadFile ( proto_path ) . splitlines ( ) start_pattern = input_api . re . compile ( PROTO_DEFINITION_START_PATTERN ) end_pattern = input_api . re . compile ( PROTO_DEFINITION_END_PATTERN ) in_proto_def = False for line in proto_file_contents : if start_pattern . match ( line ) : in_proto_def = True continue if in_proto_def : if end_pattern . match ( line ) : break line = line . strip ( ) split_proto_line = line . split ( ' ' ) if '//' in line or len ( split_proto_line ) < 3 : continue field_typename = split_proto_line [ 0 ] field_identifier = split_proto_line [ 1 ] proto_field_definitions [ field_typename ] = field_identifier return proto_field_definitions
Parses proto field identifiers from the EntitySpecifics definition.
Parses proto field identifiers from the EntitySpecifics definition .
"""Parses proto field identifiers from the EntitySpecifics definition.
  Args:
    input_api: presubmit_support InputAPI instance
    proto_path: path to the file containing the proto field definitions
  Returns:
    A dictionary of the format {'SyncDataType': 'field_identifier'}
    e.g. {'AutofillSpecifics': 'autofill'}
  """ # ignore comments and lines that don't contain definitions.
A dictionary of the format {'SyncDataType': 'field_identifier'}
e.g. {'AutofillSpecifics': 'autofill'}
A dictionary of the format { ' SyncDataType ' : ' field_identifier ' } e . g . { ' AutofillSpecifics ' : ' autofill ' }
input_api
presubmit_support InputAPI instance
presubmit_support InputAPI instance
proto_path
path to the file containing the proto field definitions
path to the file containing the proto field definitions