Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/netedit/scripts/getMissingTest.py
169678 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
4
# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.
5
# This program and the accompanying materials are made available under the
6
# terms of the Eclipse Public License 2.0 which is available at
7
# https://www.eclipse.org/legal/epl-2.0/
8
# This Source Code may also be made available under the following Secondary
9
# Licenses when the conditions for such availability set forth in the Eclipse
10
# Public License 2.0 are satisfied: GNU General Public License, version 2
11
# or later which is available at
12
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
13
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
14
15
# @file getMissingTest.py
16
# @author Pablo Alvarez Lopez
17
# @date 2022-03-21
18
19
import os
20
import scandir
21
22
23
def removeFrom(line):
24
index = line.find("netedit.attrs.")
25
if index != -1:
26
return line[index:]
27
else:
28
return line
29
30
31
def removeTo(line):
32
solution = ""
33
while ((len(line) > 0) and ((line[0] == ".") or line[0].isalpha() or line[0].isnumeric())):
34
solution += line[0]
35
line = line[1:]
36
return solution
37
38
39
# file lists
40
fileList = []
41
42
# get all test.py
43
for paths, dirs, files in scandir.walk("../"):
44
for file in files:
45
if file.endswith("test.py"):
46
fileList.append(os.path.join(paths, file))
47
48
# and all references in sumo tools
49
for paths, dirs, files in scandir.walk("../../../tools/neteditTestFunctions"):
50
for file in files:
51
if file.endswith(".py"):
52
fileList.append(os.path.join(paths, file))
53
54
# list of references
55
references = []
56
57
# get all lines with "netedit.attrs"
58
for file in fileList:
59
with open(file, "r") as fp:
60
lines = fp.readlines()
61
for line in lines:
62
if ("netedit.attrs." in line):
63
references.append(line)
64
elif ("attrs." in line):
65
line = line.replace("attrs.", "netedit.attrs.")
66
references.append(line)
67
68
"""
69
# save references
70
with open("references.txt", "w") as fp:
71
for reference in references:
72
fp.write(reference)
73
"""
74
75
# cleaned references
76
cleanedReferences = []
77
78
# iterate over lines
79
for reference in references:
80
if ("." in line):
81
# remove first element all until (
82
reference = removeFrom(reference)
83
# remove last element until ,
84
reference = removeTo(reference)
85
# replace extra characters
86
reference = reference.replace("netedit.attrs.", "")
87
if (len(reference) > 0):
88
# add endline
89
if (reference[-1] != "\n"):
90
reference += "\n"
91
# add into cleanedReferences
92
cleanedReferences.append(reference)
93
94
95
# save cleanedReferences
96
with open("cleanedReferences.txt", "w") as fp:
97
for cleanedReference in cleanedReferences:
98
fp.write(cleanedReference)
99
100
101
# open enumsXML.txt and append to cleanedReferences
102
with open("enumsXML.txt", "r") as fp:
103
cleanedReferences += fp.readlines()
104
105
# sort
106
cleanedReferences.sort()
107
108
109
# save
110
with open("cleanedReferencesAndEnums.txt", "w") as fp:
111
for cleanedReference in cleanedReferences:
112
fp.write(cleanedReference)
113
114
115
# dictionary
116
dic = {"dummy": 1000}
117
118
# get number of
119
for reference in cleanedReferences:
120
# remove all spaces
121
reference = reference.replace(" ", "")
122
# remove all spaces
123
reference = reference.replace("+1", "")
124
# check number of dots
125
if (reference.count(".") > 1):
126
found = False
127
for key in dic:
128
if (key == reference):
129
dic[key] += 1
130
found = True
131
# add in diccionary
132
if not found:
133
dic[reference] = 0
134
135
# save missing test
136
with open("missingTest.txt", "w") as fp:
137
for key in dic:
138
if (dic[key] == 0):
139
fp.write(key)
140
141