Created
May 20, 2018 18:25
-
-
Save dmbaturin/bff21090f6a64d67dcaaf3cd35883ed6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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