Skip to content

Commit 224ada2

Browse files
JarnoEttadbridge
authored andcommitted
Review corrections.
1 parent f870269 commit 224ada2

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

tools/export/sw4stm32/__init__.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
import os
1817

18+
from os import walk, sep
1919
from os.path import splitext, basename, join, dirname
2020
from random import randint
2121
from tools.utils import mkdir
@@ -82,33 +82,30 @@ def __generate_uid(self):
8282
return "%0.9u" % randint(0, 999999999)
8383

8484
@staticmethod
85-
def filter_dot(str):
85+
def filter_dot(path):
8686
"""
8787
This function removes ./ from str.
8888
str must be converted with win_to_unix() before using this function.
8989
"""
90-
if str == None:
90+
if path is None:
9191
return None
92-
if str[:2] == './':
93-
return str[2:]
94-
return str
92+
if path[:2] == './':
93+
return path[2:]
94+
return path
9595

9696
def build_excludelist(self):
9797
self.source_folders = [self.filter_dot(s) for s in set(dirname(
9898
src) for src in self.resources.c_sources + self.resources.cpp_sources + self.resources.s_sources)]
9999
if '.' in self.source_folders:
100100
self.source_folders.remove('.')
101-
#print source_folders
102101

103102
top_folders = [f for f in set(s.split('/')[0] for s in self.source_folders)]
104-
#print top_folders
105103

106104
for top_folder in top_folders:
107-
#
108-
for root, dirs, files in os.walk(top_folder, topdown=True):
105+
for root, dirs, files in walk(top_folder, topdown=True):
109106
# Paths returned by os.walk() must be split with os.dep
110107
# to accomodate Windows weirdness.
111-
parts = root.split(os.sep)
108+
parts = root.split(sep)
112109
self.remove_unused('/'.join(parts))
113110

114111
def remove_unused(self, path):
@@ -144,26 +141,20 @@ def generate(self):
144141
libraries.append(l[3:])
145142

146143
self.include_path = [self.filter_dot(s) for s in self.resources.inc_dirs]
147-
print 'Include folders: {0}'.format(len(self.include_path))
148-
#for dir in self.include_path:
149-
# print "%s" % dir
144+
print 'Include folders: %d' % len(self.include_path)
150145

151146
self.exclude_dirs = []
152147
self.build_excludelist()
153148

154-
print 'Exclude folders: {0}'.format(len(self.exclude_dirs))
155-
#for dir in self.exclude_dirs:
156-
# print "%s" % dir
149+
print 'Exclude folders: %d' % len(self.exclude_dirs)
157150

158151
self.exclude_dirs = '|'.join(self.exclude_dirs)
159152

160153
self.ld_script = self.filter_dot(self.resources.linker_script)
161-
#print 'Linker script: {0}'.format(self.ld_script)
162154

163155
self.lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs]
164156

165157
self.symbols = [s.replace('"', '"') for s in self.toolchain.get_symbols()]
166-
#print "%s" % self.symbols
167158

168159
ctx = {
169160
'name': self.project_name,

0 commit comments

Comments
 (0)