import os
import scandir
def removeFrom(line):
index = line.find("netedit.attrs.")
if index != -1:
return line[index:]
else:
return line
def removeTo(line):
solution = ""
while ((len(line) > 0) and ((line[0] == ".") or line[0].isalpha() or line[0].isnumeric())):
solution += line[0]
line = line[1:]
return solution
fileList = []
for paths, dirs, files in scandir.walk("../"):
for file in files:
if file.endswith("test.py"):
fileList.append(os.path.join(paths, file))
for paths, dirs, files in scandir.walk("../../../tools/neteditTestFunctions"):
for file in files:
if file.endswith(".py"):
fileList.append(os.path.join(paths, file))
references = []
for file in fileList:
with open(file, "r") as fp:
lines = fp.readlines()
for line in lines:
if ("netedit.attrs." in line):
references.append(line)
elif ("attrs." in line):
line = line.replace("attrs.", "netedit.attrs.")
references.append(line)
"""
# save references
with open("references.txt", "w") as fp:
for reference in references:
fp.write(reference)
"""
cleanedReferences = []
for reference in references:
if ("." in line):
reference = removeFrom(reference)
reference = removeTo(reference)
reference = reference.replace("netedit.attrs.", "")
if (len(reference) > 0):
if (reference[-1] != "\n"):
reference += "\n"
cleanedReferences.append(reference)
with open("cleanedReferences.txt", "w") as fp:
for cleanedReference in cleanedReferences:
fp.write(cleanedReference)
with open("enumsXML.txt", "r") as fp:
cleanedReferences += fp.readlines()
cleanedReferences.sort()
with open("cleanedReferencesAndEnums.txt", "w") as fp:
for cleanedReference in cleanedReferences:
fp.write(cleanedReference)
dic = {"dummy": 1000}
for reference in cleanedReferences:
reference = reference.replace(" ", "")
reference = reference.replace("+1", "")
if (reference.count(".") > 1):
found = False
for key in dic:
if (key == reference):
dic[key] += 1
found = True
if not found:
dic[reference] = 0
with open("missingTest.txt", "w") as fp:
for key in dic:
if (dic[key] == 0):
fp.write(key)