Skip to content

Commit 9a66835

Browse files
committed
python: Removed double \ from regex literal strings.
1 parent 17f4915 commit 9a66835

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

python/inet/common/compile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def get_parameters_string(self, **kwargs):
6868

6969
def get_input_files(self):
7070
output_folder = f"out/clang-{self.mode}"
71-
object_path = re.sub(r"\\.msg", "_m.cc", self.file_path)
72-
dependency_file_path = re.sub(r"\\.msg", "_m.h.d", self.file_path)
71+
object_path = re.sub(r"\.msg", "_m.cc", self.file_path)
72+
dependency_file_path = re.sub(r"\.msg", "_m.h.d", self.file_path)
7373
full_file_path = self.simulation_project.get_full_path(os.path.join(output_folder, dependency_file_path))
7474
if os.path.exists(full_file_path):
7575
dependency = read_dependency_file(full_file_path)
@@ -80,14 +80,14 @@ def get_input_files(self):
8080
return [self.file_path]
8181

8282
def get_output_files(self):
83-
cpp_file_path = re.sub(r"\\.msg", "_m.cc", self.file_path)
84-
header_file_path = re.sub(r"\\.msg", "_m.h", self.file_path)
83+
cpp_file_path = re.sub(r"\.msg", "_m.cc", self.file_path)
84+
header_file_path = re.sub(r"\.msg", "_m.h", self.file_path)
8585
return [f"{cpp_file_path}", f"{header_file_path}"]
8686

8787
def get_arguments(self):
8888
executable = "opp_msgc"
8989
output_folder = f"out/clang-{self.mode}"
90-
header_file_path = re.sub(r"\\.msg", "_m.h", self.file_path)
90+
header_file_path = re.sub(r"\.msg", "_m.h", self.file_path)
9191
import_paths = list(map(lambda msg_folder: self.simulation_project.get_full_path(msg_folder), self.simulation_project.msg_folders))
9292
return [executable,
9393
"--msg6",
@@ -118,8 +118,8 @@ def get_parameters_string(self, **kwargs):
118118

119119
def get_input_files(self):
120120
output_folder = f"out/clang-{self.mode}"
121-
object_path = re.sub(r"\\.cc", ".o", self.file_path)
122-
dependency_file_path = re.sub(r"\\.cc", ".o.d", self.file_path)
121+
object_path = re.sub(r"\.cc", ".o", self.file_path)
122+
dependency_file_path = re.sub(r"\.cc", ".o.d", self.file_path)
123123
full_file_path = self.simulation_project.get_full_path(os.path.join(output_folder, dependency_file_path))
124124
if os.path.exists(full_file_path):
125125
dependency = read_dependency_file(full_file_path)
@@ -130,7 +130,7 @@ def get_input_files(self):
130130

131131
def get_output_files(self):
132132
output_folder = f"out/clang-{self.mode}"
133-
object_path = re.sub(r"\\.cc", ".o", self.file_path)
133+
object_path = re.sub(r"\.cc", ".o", self.file_path)
134134
return [f"{output_folder}/{object_path}"]
135135

136136
def get_arguments(self):

python/inet/simulation/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def __init__(self, simulation_project=None, name="MSG compile task", mode="relea
117117
self.simulation_project = simulation_project
118118
self.mode = mode
119119
self.input_files = list(map(lambda input_file: self.simulation_project.get_full_path(input_file), self.simulation_project.get_msg_files()))
120-
self.output_files = list(map(lambda output_file: re.sub(r"\\.msg", "_m.cc", output_file), self.input_files)) + \
121-
list(map(lambda output_file: re.sub(r"\\.msg", "_m.h", output_file), self.input_files))
120+
self.output_files = list(map(lambda output_file: re.sub(r"\.msg", "_m.cc", output_file), self.input_files)) + \
121+
list(map(lambda output_file: re.sub(r"\.msg", "_m.h", output_file), self.input_files))
122122

123123
def get_description(self):
124124
return self.simulation_project.get_name() + " " + super().get_description()
@@ -165,7 +165,7 @@ def get_object_files(self):
165165
object_files = []
166166
for cpp_folder in self.simulation_project.cpp_folders:
167167
file_paths = glob.glob(self.simulation_project.get_full_path(os.path.join(cpp_folder, "**/*.cc")), recursive=True)
168-
object_files = object_files + list(map(lambda file_path: os.path.join(output_folder, self.simulation_project.get_relative_path(re.sub(r"\\.cc", ".o", file_path))), file_paths))
168+
object_files = object_files + list(map(lambda file_path: os.path.join(output_folder, self.simulation_project.get_relative_path(re.sub(r"\.cc", ".o", file_path))), file_paths))
169169
return object_files
170170

171171
def is_up_to_date(self):
@@ -280,7 +280,7 @@ def get_build_tasks(self, **kwargs):
280280
os.makedirs(output_folder)
281281
msg_compile_tasks = list(map(lambda msg_file: MsgCompileTask(simulation_project=self.simulation_project, file_path=msg_file, mode=self.mode), self.simulation_project.get_msg_files()))
282282
multiple_msg_compile_tasks = MultipleMsgCompileTasks(simulation_project=self.simulation_project, mode=self.mode, tasks=msg_compile_tasks, concurrent=self.concurrent_child_tasks)
283-
msg_cpp_compile_tasks = list(map(lambda msg_file: CppCompileTask(simulation_project=self.simulation_project, file_path=re.sub(r"\\.msg", "_m.cc", msg_file), mode=self.mode), self.simulation_project.get_msg_files()))
283+
msg_cpp_compile_tasks = list(map(lambda msg_file: CppCompileTask(simulation_project=self.simulation_project, file_path=re.sub(r"\.msg", "_m.cc", msg_file), mode=self.mode), self.simulation_project.get_msg_files()))
284284
cpp_compile_tasks = list(map(lambda cpp_file: CppCompileTask(simulation_project=self.simulation_project, file_path=cpp_file, mode=self.mode), self.simulation_project.get_cpp_files()))
285285
all_cpp_compile_tasks = msg_cpp_compile_tasks + cpp_compile_tasks
286286
multiple_cpp_compile_tasks = MultipleCppCompileTasks(simulation_project=self.simulation_project, mode=self.mode, tasks=all_cpp_compile_tasks, concurrent=self.concurrent_child_tasks)

python/inet/simulation/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ def get_effective_include_folders(self):
271271
def get_cpp_files(self):
272272
cpp_files = []
273273
for cpp_folder in self.cpp_folders:
274-
file_paths = list(filter(lambda file_path: not re.search(r"_m\\.cc", file_path), glob.glob(self.get_full_path(os.path.join(cpp_folder, "**/*.cc")), recursive=True)))
274+
file_paths = list(filter(lambda file_path: not re.search(r"_m\.cc", file_path), glob.glob(self.get_full_path(os.path.join(cpp_folder, "**/*.cc")), recursive=True)))
275275
cpp_files = cpp_files + list(map(lambda file_path: self.get_relative_path(file_path), file_paths))
276276
return cpp_files
277277

278278
def get_header_files(self):
279279
header_files = []
280280
for cpp_folder in self.cpp_folders:
281-
file_paths = list(filter(lambda file_path: not re.search(r"_m\\.h", file_path), glob.glob(self.get_full_path(os.path.join(cpp_folder, "**/*.h")), recursive=True)))
281+
file_paths = list(filter(lambda file_path: not re.search(r"_m\.h", file_path), glob.glob(self.get_full_path(os.path.join(cpp_folder, "**/*.h")), recursive=True)))
282282
header_files = header_files + list(map(lambda file_path: self.get_relative_path(file_path), file_paths))
283283
return header_files
284284

@@ -313,7 +313,7 @@ def create_config_dict(config):
313313
config_dicts = {"General": create_config_dict("General")}
314314
config_dict = {}
315315
for line in file:
316-
match = re.match(r"\\[(Config +)?(.*?)\\]", line)
316+
match = re.match(r"\[(Config +)?(.*?)\]", line)
317317
if match:
318318
config = match.group(2) or match.group(3)
319319
config_dict = create_config_dict(config)

python/inet/test/feature.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@ def read_xml_file(filename, repair_hint=None):
109109

110110
def get_package_folder(package):
111111
if re.search(r"inet.examples", package):
112-
return re.sub(r"inet/", "", re.sub(r"\\.", "/", package))
112+
return re.sub(r"inet/", "", re.sub(r"\.", "/", package))
113113
elif re.search(r"inet.showcases", package):
114-
return re.sub(r"inet/", "", re.sub(r"\\.", "/", package))
114+
return re.sub(r"inet/", "", re.sub(r"\.", "/", package))
115115
elif re.search(r"inet.tutorials", package):
116-
return re.sub(r"inet/", "", re.sub(r"\\.", "/", package))
116+
return re.sub(r"inet/", "", re.sub(r"\.", "/", package))
117117
elif re.search(r"inet.tests", package):
118-
return re.sub(r"inet/", "", re.sub(r"\\.", "/", package))
118+
return re.sub(r"inet/", "", re.sub(r"\.", "/", package))
119119
elif re.search(r"inet.validation", package):
120-
return re.sub(r"inet/", "tests/", re.sub(r"\\.", "/", package))
120+
return re.sub(r"inet/", "tests/", re.sub(r"\.", "/", package))
121121
else:
122-
return "src/" + re.sub(r"\\.", "/", package)
122+
return "src/" + re.sub(r"\.", "/", package)
123123

124124
def get_features(oppfeatures):
125125
result = []

python/inet/test/statistical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def check_simulation_task_result(self, simulation_task_result, result_name_filte
8484
id = next(iter(df.index), None)
8585
reason = df.loc[id].to_string()
8686
reason = re.sub(r" +", " = ", reason)
87-
reason = re.sub(r"\\n", ", ", reason)
87+
reason = re.sub(r"\n", ", ", reason)
8888
return self.task_result_class(task=self, simulation_task_result=simulation_task_result, result="FAIL", reason=reason)
8989
else:
9090
return self.task_result_class(task=self, simulation_task_result=simulation_task_result, result="PASS")

python/inet/test/validation.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ def compute_asynchronousshaper_icct_endtoend_delay_from_simulation_results(**kwa
109109
filter_expression = """type =~ scalar AND name =~ meanBitLifeTimePerPacket:histogram:max"""
110110
df = read_result_files(inet_project.get_full_path("tests/validation/tsn/trafficshaping/asynchronousshaper/icct/results/*.sca"), filter_expression=filter_expression, include_fields_as_scalars=True)
111111
df = get_scalars(df)
112-
df["name"] = df["name"].map(lambda name: re.sub(r".*(min|max)", "\\1", name))
113-
df["module"] = df["module"].map(lambda name: re.sub(r".*N6.app\\[[0-4]\\].*", "Flow 4, Class A", name))
114-
df["module"] = df["module"].map(lambda name: re.sub(r".*N6.app\\[[5-9]\\].*", "Flow 5, Class B", name))
115-
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\\[[0-9]\\].*", "Flow 1, CDT", name))
116-
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\\[1[0-9]\\].*", "Flow 2, Class A", name))
117-
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\\[2[0-9]\\].*", "Flow 3, Class B", name))
118-
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\\[3[0-4]\\].*", "Flow 6, Class A", name))
119-
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\\[3[5-9]\\].*", "Flow 7, Class B", name))
120-
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\\[40\\].*", "Flow 8, Best Effort", name))
112+
df["name"] = df["name"].map(lambda name: re.sub(r".*(min|max)", "\1", name))
113+
df["module"] = df["module"].map(lambda name: re.sub(r".*N6.app\[[0-4]\].*", "Flow 4, Class A", name))
114+
df["module"] = df["module"].map(lambda name: re.sub(r".*N6.app\[[5-9]\].*", "Flow 5, Class B", name))
115+
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\[[0-9]\].*", "Flow 1, CDT", name))
116+
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\[1[0-9]\].*", "Flow 2, Class A", name))
117+
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\[2[0-9]\].*", "Flow 3, Class B", name))
118+
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\[3[0-4]\].*", "Flow 6, Class A", name))
119+
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\[3[5-9]\].*", "Flow 7, Class B", name))
120+
df["module"] = df["module"].map(lambda name: re.sub(r".*N7.app\[40\].*", "Flow 8, Best Effort", name))
121121
df = pd.pivot_table(df, index="module", columns="name", values="value", aggfunc="max")
122122
return df * 1000000
123123

@@ -155,11 +155,11 @@ def compute_asynchronousshaper_core4inet_endtoend_delay_from_simulation_results(
155155
filter_expression = """type =~ scalar AND (name =~ meanBitLifeTimePerPacket:histogram:min OR name =~ meanBitLifeTimePerPacket:histogram:max OR name =~ meanBitLifeTimePerPacket:histogram:mean OR name =~ meanBitLifeTimePerPacket:histogram:stddev)"""
156156
df = read_result_files(inet_project.get_full_path("tests/validation/tsn/trafficshaping/asynchronousshaper/core4inet/results/*.sca"), filter_expression=filter_expression, include_fields_as_scalars=True)
157157
df = get_scalars(df)
158-
df["name"] = df["name"].map(lambda name: re.sub(r".*(min|max|mean|stddev)", "\\1", name))
159-
df["module"] = df["module"].map(lambda name: re.sub(r".*app\\[0\\].*", "Best effort", name))
160-
df["module"] = df["module"].map(lambda name: re.sub(r".*app\\[1\\].*", "Medium", name))
161-
df["module"] = df["module"].map(lambda name: re.sub(r".*app\\[2\\].*", "High", name))
162-
df["module"] = df["module"].map(lambda name: re.sub(r".*app\\[3\\].*", "Critical", name))
158+
df["name"] = df["name"].map(lambda name: re.sub(r".*(min|max|mean|stddev)", "\1", name))
159+
df["module"] = df["module"].map(lambda name: re.sub(r".*app\[0\].*", "Best effort", name))
160+
df["module"] = df["module"].map(lambda name: re.sub(r".*app\[1\].*", "Medium", name))
161+
df["module"] = df["module"].map(lambda name: re.sub(r".*app\[2\].*", "High", name))
162+
df["module"] = df["module"].map(lambda name: re.sub(r".*app\[3\].*", "Critical", name))
163163
df = df.loc[df["module"]!="Best effort"]
164164
df = pd.pivot_table(df, index="module", columns="name", values="value")
165165
return df * 1000000
@@ -222,11 +222,11 @@ def compute_creditbasedshaper_endtoend_delay_from_simulation_results(**kwargs):
222222
filter_expression = """type =~ scalar AND (name =~ meanBitLifeTimePerPacket:histogram:min OR name =~ meanBitLifeTimePerPacket:histogram:max OR name =~ meanBitLifeTimePerPacket:histogram:mean OR name =~ meanBitLifeTimePerPacket:histogram:stddev)"""
223223
df = read_result_files(inet_project.get_full_path("tests/validation/tsn/trafficshaping/creditbasedshaper/results/*.sca"), filter_expression=filter_expression, include_fields_as_scalars=True)
224224
df = get_scalars(df)
225-
df["name"] = df["name"].map(lambda name: re.sub(r".*(min|max|mean|stddev)", "\\1", name))
226-
df["module"] = df["module"].map(lambda name: re.sub(r".*app\\[0\\].*", "Best effort", name))
227-
df["module"] = df["module"].map(lambda name: re.sub(r".*app\\[1\\].*", "Medium", name))
228-
df["module"] = df["module"].map(lambda name: re.sub(r".*app\\[2\\].*", "High", name))
229-
df["module"] = df["module"].map(lambda name: re.sub(r".*app\\[3\\].*", "Critical", name))
225+
df["name"] = df["name"].map(lambda name: re.sub(r".*(min|max|mean|stddev)", "\1", name))
226+
df["module"] = df["module"].map(lambda name: re.sub(r".*app\[0\].*", "Best effort", name))
227+
df["module"] = df["module"].map(lambda name: re.sub(r".*app\[1\].*", "Medium", name))
228+
df["module"] = df["module"].map(lambda name: re.sub(r".*app\[2\].*", "High", name))
229+
df["module"] = df["module"].map(lambda name: re.sub(r".*app\[3\].*", "Critical", name))
230230
df = df.loc[df["module"]!="Best effort"]
231231
df = pd.pivot_table(df, index="module", columns="name", values="value")
232232
return df * 1000000

0 commit comments

Comments
 (0)