Skip to content

Commit 2e5fd74

Browse files
theotherjimmyadbridge
authored andcommitted
Use os.sep and os.join instead of string ops
1 parent 50ceca7 commit 2e5fd74

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tools/memap.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def parse_object_name_gcc(self, line):
136136
txt - the path to parse the object and module name from
137137
"""
138138

139-
line = line.replace('\\', '/')
140139
test_re_mbed_os_name = re.match(RE_OBJECT_FILE_GCC, line)
141140

142141
if test_re_mbed_os_name:
@@ -145,18 +144,18 @@ def parse_object_name_gcc(self, line):
145144

146145
# corner case: certain objects are provided by the GCC toolchain
147146
if 'arm-none-eabi' in line:
148-
return '[lib]/misc/' + object_name
147+
return os.path.join('[lib]', 'misc', object_name)
149148
return object_name
150149

151150
else:
152151

153152
test_re_obj_name = re.match(RE_LIBRARY_OBJECT_GCC, line)
154153

155154
if test_re_obj_name:
156-
object_name = test_re_obj_name.group(1) + '/' + \
157-
test_re_obj_name.group(2)
155+
object_name = os.path.join(test_re_obj_name.group(1),
156+
test_re_obj_name.group(2))
158157

159-
return '[lib]/' + object_name
158+
return os.path.join('[lib]', object_name)
160159

161160
else:
162161
print "Unknown object name found in GCC map file: %s" % line
@@ -241,8 +240,9 @@ def parse_object_name_armcc(self, line):
241240
else:
242241
is_obj = re.match(RE_OBJECT_ARMCC, line)
243242
if is_obj:
244-
object_name = os.path.basename(is_obj.group(1)) + '/' + is_obj.group(3)
245-
return '[lib]/' + object_name
243+
object_name = os.path.join(os.path.basename(is_obj.group(1)),
244+
is_obj.group(3))
245+
return os.path.join('[lib]', object_name)
246246
else:
247247
print "Malformed input found when parsing ARMCC map: %s" % line
248248
return '[misc]'
@@ -472,7 +472,7 @@ def parse_map_file_iar(self, file_desc):
472472
object_name = self.check_new_object_lib_iar(line)
473473

474474
if object_name and current_library:
475-
temp = '[lib]' + '/'+ current_library + '/'+ object_name
475+
temp = os.path.join('[lib]', current_library, object_name)
476476
self.module_replace(object_name, temp)
477477

478478

@@ -495,10 +495,10 @@ def reduce_depth(self, depth):
495495
else:
496496
self.short_modules = dict()
497497
for module_name, v in self.modules.items():
498-
split_name = module_name.split('/')
498+
split_name = module_name.split(os.sep)
499499
if split_name[0] == '':
500500
split_name = split_name[1:]
501-
new_name = "/".join(split_name[:depth])
501+
new_name = os.path.join(*split_name[:depth])
502502
self.short_modules.setdefault(new_name, {})
503503
for section_idx, value in v.items():
504504
self.short_modules[new_name].setdefault(section_idx, 0)

0 commit comments

Comments
 (0)