Starting the newer version ; currently, preprocessor directives are managed

This commit is contained in:
Némunaire 2011-10-31 02:39:04 +00:00
parent 28f6dfa2aa
commit 98095ca4ed
5 changed files with 182 additions and 52 deletions

View file

@ -4,13 +4,6 @@ import sys
import os
import re
def onSignal(signal, frame):
print("Bye!")
sys.exit(0)
signal.signal(signal.SIGINT, onSignal)
if len(sys.argv) < 2:
print("Usage:\t{0} FILE...".format(sys.argv[0]))
sys.exit(1)
@ -66,14 +59,6 @@ def checkDir(path):
printError(path + '/' + basename, "Hidden file")
checkFile(path + '/' + f)
def check80cols(path, line, num):
if len(line) > 79:
printError(path, "80 columns exceeded", num)
def checkTrailingWhitespace(path, line, num):
if len(line) > 1 and (line[len(line)-1] == ' ' or line[len(line)-1] == '\t'):
printError(path, "Trailing whitespace", num)
def checkCComment(path, line, num):
txt = line.strip()
if re.match("\*/", txt) is not None:
@ -164,43 +149,6 @@ def checkCFile(path):
else:
typeBlock = checkCLang(path, line, num)
def checkSHFile(path):
num = 0
with open(path, "r") as fp:
lines = fp.read().split('\n')
for line in lines:
num += 1
line = line.replace(" ", " ")
check80cols(path, line, num)
checkTrailingWhitespace(path, line, num)
def checkOtherFile(path):
num = 0
with open(path, "r") as fp:
lines = fp.read().split('\n')
for line in lines:
num += 1
line = line.replace(" ", " ")
checkTrailingWhitespace(path, line, num)
def checkAuthors(path):
num = 0
with open(path, "r") as fp:
fullContent = fp.read()
if fullContent < 1 or fullContent[len(fullContent)-1] != '\n':
printError(path, "No empty line at the end of file")
lines = fullContent.split('\n')
for line in lines:
num += 1
checkTrailingWhitespace(path, line, num)
if re.match("^(\* [a-z][a-z-]{,5}_[a-z0-9])?$", line) is None:
printError(path, "Bad author format", num)
#Define some constants