mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 08:37:22 +00:00
fix regex string
This commit is contained in:
parent
cc9ec05d11
commit
b5c1b08d78
@ -41,7 +41,7 @@ copyright = """/*
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
onlyDumpDifferentCopyright = False
|
onlyDumpDifferentCopyright = False
|
||||||
copyrightString = "Copyright (C) 2014 BlueKitchen GmbH"
|
copyrightString = "Copyright \(C\) 2014 BlueKitchen GmbH"
|
||||||
copyrighters = ["BlueKitchen", "Matthias Ringwald"]
|
copyrighters = ["BlueKitchen", "Matthias Ringwald"]
|
||||||
|
|
||||||
ignoreFolders = ["cpputest", "test", "msp-exp430f5438-cc2564b", "msp430f5229lp-cc2564b", "ez430-rf2560", "ios", "chipset-cc256x", "docs", "mtk"]
|
ignoreFolders = ["cpputest", "test", "msp-exp430f5438-cc2564b", "msp430f5229lp-cc2564b", "ez430-rf2560", "ios", "chipset-cc256x", "docs", "mtk"]
|
||||||
@ -54,11 +54,11 @@ class State:
|
|||||||
SearchEndComment = 2
|
SearchEndComment = 2
|
||||||
|
|
||||||
def updateCopyright(dir_name, file_name):
|
def updateCopyright(dir_name, file_name):
|
||||||
print file_name, ": Update copyright"
|
|
||||||
|
|
||||||
infile = dir_name + "/" + file_name
|
infile = dir_name + "/" + file_name
|
||||||
outfile = dir_name + "/tmp_" + file_name
|
outfile = dir_name + "/tmp_" + file_name
|
||||||
|
|
||||||
|
#print "Update copyright: ", infile
|
||||||
|
|
||||||
with open(outfile, 'w') as fout:
|
with open(outfile, 'w') as fout:
|
||||||
fout.write(copyright)
|
fout.write(copyright)
|
||||||
|
|
||||||
@ -96,26 +96,28 @@ def updateCopyright(dir_name, file_name):
|
|||||||
|
|
||||||
os.rename(outfile, infile)
|
os.rename(outfile, infile)
|
||||||
|
|
||||||
|
|
||||||
def requiresCopyrightUpdate(file_name):
|
def requiresCopyrightUpdate(file_name):
|
||||||
global copyrightString, onlyDumpDifferentCopyright
|
global copyrightString, onlyDumpDifferentCopyright
|
||||||
|
|
||||||
with open(file_name, "rb") as fin:
|
with open(file_name, "rb") as fin:
|
||||||
parts = []
|
|
||||||
allowedCopyrighters = []
|
|
||||||
|
|
||||||
for line in fin:
|
for line in fin:
|
||||||
parts = re.match('.*(Copyright).*',line, re.I)
|
parts = re.match('.*('+copyrightString+').*',line, re.I)
|
||||||
if parts:
|
if parts:
|
||||||
allowedCopyrighterFound = False
|
continue
|
||||||
for name in copyrighters:
|
|
||||||
allowedCopyrighters = re.match('.*('+name+').*',line, re.I)
|
|
||||||
if allowedCopyrighters:
|
|
||||||
allowedCopyrighterFound = True
|
|
||||||
return not re.match('.*('+copyrightString+').*',line)
|
|
||||||
|
|
||||||
if not allowedCopyrighterFound and onlyDumpDifferentCopyright:
|
parts = re.match('.*(Copyright).*',line, re.I)
|
||||||
print file_name, ": Copyrighter not allowed > ", parts.group()
|
if not parts:
|
||||||
return False
|
continue
|
||||||
|
|
||||||
|
for name in copyrighters:
|
||||||
|
allowedCopyrighters = re.match('.*('+name+').*',line, re.I)
|
||||||
|
if allowedCopyrighters:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if onlyDumpDifferentCopyright:
|
||||||
|
print file_name, ": Copyrighter not allowed > ", parts.group()
|
||||||
|
return False
|
||||||
|
|
||||||
print file_name, ": File has no copyright"
|
print file_name, ": File has no copyright"
|
||||||
return False
|
return False
|
||||||
@ -128,7 +130,7 @@ for root, dirs, files in os.walk('../', topdown=True):
|
|||||||
if f.endswith(".h") or f.endswith(".c"):
|
if f.endswith(".h") or f.endswith(".c"):
|
||||||
file_name = root + "/" + f
|
file_name = root + "/" + f
|
||||||
if requiresCopyrightUpdate(file_name):
|
if requiresCopyrightUpdate(file_name):
|
||||||
updateCopyright(file_name)
|
updateCopyright(root, f)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user