components/autofill/PRESUBMIT.py
def _CheckFeatureNames(input_api, output_api):
  """Checks that no features are enabled."""

  pattern = input_api.re.compile(
          r'\bbase::Feature\s+k(\w*)\s*{\s*"(\w*)"',
          input_api.re.MULTILINE)
  warnings = []

  def exception(constant, feature):
    if constant == "AutofillAddressEnhancementVotes" and \
       feature == "kAutofillAddressEnhancementVotes":
      return True
    return False

  for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
    if (f.LocalPath().startswith('components/autofill/') and
        f.LocalPath().endswith('features.cc')):
      contents = input_api.ReadFile(f)
      mismatches = [(constant, feature)
              for (constant, feature) in pattern.findall(contents)
              if constant != feature and not exception(constant, feature)]
      if mismatches:
        mismatch_strings = ['\t{} -- {}'.format(*m) for m in mismatches]
        mismatch_string = format('\n').join(mismatch_strings)
        warnings += [ output_api.PresubmitPromptWarning(
            'Feature names should be identical to variable names:\n{}'
                .format(mismatch_string),
            [f]) ]

  return warnings
Checks that no features are enabled.
Checks that no features are enabled.
Checks that no features are enabled .
def _CheckFeatureNames(input_api, output_api):
  pattern = input_api.re.compile(
          r'\bbase::Feature\s+k(\w*)\s*{\s*"(\w*)"',
          input_api.re.MULTILINE)
  warnings = []
  def exception(constant, feature):
    if constant == "AutofillAddressEnhancementVotes" and \
       feature == "kAutofillAddressEnhancementVotes":
      return True
    return False
  for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
    if (f.LocalPath().startswith('components/autofill/') and
        f.LocalPath().endswith('features.cc')):
      contents = input_api.ReadFile(f)
      mismatches = [(constant, feature)
              for (constant, feature) in pattern.findall(contents)
              if constant != feature and not exception(constant, feature)]
      if mismatches:
        mismatch_strings = ['\t{} -- {}'.format(*m) for m in mismatches]
        mismatch_string = format('\n').join(mismatch_strings)
        warnings += [ output_api.PresubmitPromptWarning(
            'Feature names should be identical to variable names:\n{}'
                .format(mismatch_string),
            [f]) ]
  return warnings
def _CheckFeatureNames ( input_api , output_api ) : pattern = input_api . re . compile ( r'\bbase::Feature\s+k(\w*)\s*{\s*"(\w*)"' , input_api . re . MULTILINE ) warnings = [ ] def exception ( constant , feature ) : if constant == "AutofillAddressEnhancementVotes" and feature == "kAutofillAddressEnhancementVotes" : return True return False for f in input_api . AffectedSourceFiles ( input_api . FilterSourceFile ) : if ( f . LocalPath ( ) . startswith ( 'components/autofill/' ) and f . LocalPath ( ) . endswith ( 'features.cc' ) ) : contents = input_api . ReadFile ( f ) mismatches = [ ( constant , feature ) for ( constant , feature ) in pattern . findall ( contents ) if constant != feature and not exception ( constant , feature ) ] if mismatches : mismatch_strings = [ '\t{} -- {}' . format ( * m ) for m in mismatches ] mismatch_string = format ( '\n' ) . join ( mismatch_strings ) warnings += [ output_api . PresubmitPromptWarning ( 'Feature names should be identical to variable names:\n{}' . format ( mismatch_string ) , [ f ] ) ] return warnings
Checks that no features are enabled.
Checks that no features are enabled .
"""Checks that no features are enabled."""
input_api
output_api