- fo = open(patch_file, 'r')
- lines = fo.readlines()
-
- for line in lines:
- if file_content_list.search(line) and not \
- file_content_project_list.search(line):
- match = file_content_list.search(line)
- logger.error('File contains violation: %s', patch_file)
- logger.error('Flagged Content: %s', line.rstrip())
- logger.error('Matched String: %s', match.group())
- failure = True
- with open(reports_dir + "contents_" + project + ".log",
- "a") as gate_report:
- gate_report.write('File contains violation: {0}\n'.
- format(patch_file))
- gate_report.write('Flagged Content: {0}'.
- format(line))
- gate_report.write('Matched String: {0}\n'.
- format(match.group()))
-
- # Run license check
- licence_check(project, licence_ext, licence_ignore, patch_file)
+ try:
+ fo = open(patch_file, 'r')
+ lines = fo.readlines()
+ file_exists = True
+ except IOError:
+ file_exists = False
+
+ if file_exists and not patch_file.endswith(tuple(file_ignore)):
+ for line in lines:
+ for key, value in master_list.iteritems():
+ regex = value['regex']
+ desc = value['desc']
+ if re.search(regex, line) and not re.search(
+ ignore_list, line):
+ logger.error('File contains violation: %s', patch_file)
+ logger.error('Flagged Content: %s', line.rstrip())
+ logger.error('Matched Regular Exp: %s', regex)
+ logger.error('Rationale: %s', desc.rstrip())
+ failure = True
+ with open(reports_dir + "contents_" + project + ".log",
+ "a") as gate_report:
+ gate_report.write('File contains violation: {0}\n'.
+ format(patch_file))
+ gate_report.write('Flagged Content: {0}'.
+ format(line))
+ gate_report.write('Matched Regular Exp: {0}\n'.
+ format(regex))
+ gate_report.write('Rationale: {0}\n'.
+ format(desc.rstrip()))
+ # Run license check
+ licence_check(project, licence_ext, licence_ignore, patch_file)