Created
January 17, 2013 22:18
-
-
Save theikkila/4560348 to your computer and use it in GitHub Desktop.
Calculates braces in file
If eq prints OK, else FAIL
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
# Calculates braces in file | |
# If eq prints OK, else FAIL | |
import sys | |
fname = sys.argv[1] | |
file = open(fname, 'r') | |
OKGREEN = '\033[92m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
open = 0 | |
close = 0 | |
for char in file.read(): | |
if char == '{': | |
open+=1 | |
if char == '}': | |
close+=1 | |
if open != close: | |
print (FAIL+"FAIL ("+fname+")"+ENDC) | |
else: | |
print(OKGREEN+"OK ("+fname+")"+ENDC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment