def _get_safecommit_count(filename):
 report_contents = _get_report_contents(filename)
 if ('No files linted' in report_contents):
  return 0
 file_count_regex = re.compile('^(?P<count>\\d+) violations total', re.MULTILINE)
 try:
  validation_count = None
  for count_match in file_count_regex.finditer(report_contents):
   if (validation_count is None):
    validation_count = 0
   validation_count += int(count_match.group('count'))
  return validation_count
 except ValueError:
  return None

def _get_safecommit_count ( filename ) : report_contents = _get_report_contents ( filename ) if ( 'No files linted' in report_contents ) : return 0 file_count_regex = re . compile ( '^(?P<count>\\d+) violations total' , re . MULTILINE ) try : validation_count = None for count_match in file_count_regex . finditer ( report_contents ) : if ( validation_count is None ) : validation_count = 0 validation_count += int ( count_match . group ( 'count' ) ) return validation_count except ValueError : return None
returns the violation count from the safecommit report .