Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python
import sys
import re
has_txt_type = 0
has_non_txt_type = 0
has_syntax_commit_expr_txt = 0
has_syntax_commit_expr_non_txt = 0
def check_file(name):
global has_txt_type
global has_non_txt_type
global has_syntax_commit_expr_txt
global has_syntax_commit_expr_non_txt
with open(name, 'r') as f:
data = f.read()
if re.search(r'type:', data):
if re.search(r'type:\s*txt', data):
has_txt_type += 1
if re.search(r'(syntax:|commit:)', data):
has_syntax_commit_expr_txt += 1
else:
has_non_txt_type += 1
if re.search(r'(syntax:|commit:)', data):
has_syntax_commit_expr_non_txt += 1
lines = sys.stdin.readlines()
for l in lines:
check_file(l.strip())
print("Has type: {0}".format(has_txt_type + has_non_txt_type))
print("Has type txt: {0}".format(has_txt_type))
print("Has type other than txt: {0}".format(has_non_txt_type))
print("Has commit or syntax expression: {0}".format(has_syntax_commit_expr_non_txt + has_syntax_commit_expr_txt))
print("Has commit or syntax expression and type txt: {0}".format(has_syntax_commit_expr_txt))
print("Has commit or syntax expression and type other than txt: {0}".format(has_syntax_commit_expr_non_txt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment