Skip to content

Commit 26e7a35

Browse files
theotherjimmy0xc0170
authored andcommitted
Fix remaining issues in targets.py
1 parent 6d70a7a commit 26e7a35

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

tools/targets.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __get_resolution_order(self, target_name, order, level=0):
110110
parent's parent at level 2 and so on)
111111
"""
112112
# the resolution order can't contain duplicate target names
113-
if not target_name in [l[0] for l in order]:
113+
if target_name not in [l[0] for l in order]:
114114
order.append((target_name, level))
115115
parents = self.get_json_target_data()[target_name].get("inherits", [])
116116
for par in parents:
@@ -149,17 +149,17 @@ def __getattr_cumulative(self, attrname):
149149
break
150150
else:
151151
raise AttributeError("Attribute '%s' not found in target '%s'"
152-
% (attrname, self.name))
152+
% (attrname, self.name))
153153
# Get the starting value of the attribute
154154
starting_value = (tdata[self.resolution_order[def_idx][0]][attrname]
155-
or [])[:]
155+
or [])[:]
156156
# Traverse the resolution list in high inheritance to low
157157
# inheritance level, left to right order to figure out all the
158158
# other classes that change the definition by adding or removing
159159
# elements
160160
for idx in xrange(self.resolution_order[def_idx][1] - 1, -1, -1):
161161
same_level_targets = [tar[0] for tar in self.resolution_order
162-
if tar[1] == idx]
162+
if tar[1] == idx]
163163
for tar in same_level_targets:
164164
data = tdata[tar]
165165
# Do we have anything to add ?
@@ -186,10 +186,10 @@ def __getattr_cumulative(self, attrname):
186186
else:
187187
name_def_map[crtv] = crtv
188188
for element in data[attrname + "_remove"]:
189-
if not element in name_def_map:
189+
if element not in name_def_map:
190190
raise ValueError(
191191
("Unable to remove '%s' in '%s.%s' since "
192-
% (element, self.name, attrname)) +
192+
% (element, self.name, attrname)) +
193193
"it doesn't exist")
194194
starting_value.remove(name_def_map[element])
195195
return starting_value
@@ -277,7 +277,7 @@ def get_labels(self):
277277
labels = [self.name] + CORE_LABELS[self.core] + self.extra_labels
278278
# Automatically define UVISOR_UNSUPPORTED if the target doesn't
279279
# specifically define UVISOR_SUPPORTED
280-
if not "UVISOR_SUPPORTED" in labels:
280+
if "UVISOR_SUPPORTED" not in labels:
281281
labels.append("UVISOR_UNSUPPORTED")
282282
return labels
283283

@@ -357,7 +357,8 @@ def binary_hook(t_self, resources, elf, binf):
357357
outbin.write(data)
358358
outbin.write('\xFF' * (512*1024 - len(data)))
359359
partf.close()
360-
# Read and append the second part (external flash) in chunks of fixed size
360+
# Read and append the second part (external flash) in chunks of fixed
361+
# size
361362
chunksize = 128 * 1024
362363
partf = open(os.path.join(binf, "ER_IROM2"), "rb")
363364
while True:
@@ -389,7 +390,7 @@ def binary_hook(t_self, resources, elf, binf):
389390
class MTSCode(object):
390391
"""Generic MTS code"""
391392
@staticmethod
392-
def _combine_bins_helper(target_name, t_self, resources, elf, binf):
393+
def _combine_bins_helper(target_name, binf):
393394
"""combine bins with the bootloader for a particular target"""
394395
loader = os.path.join(TOOLS_BOOTLOADERS, target_name, "bootloader.bin")
395396
target = binf + ".tmp"
@@ -418,19 +419,17 @@ def _combine_bins_helper(target_name, t_self, resources, elf, binf):
418419
@staticmethod
419420
def combine_bins_mts_dot(t_self, resources, elf, binf):
420421
"""A hook for the MTS MDOT"""
421-
MTSCode._combine_bins_helper("MTS_MDOT_F411RE", t_self, resources, elf,
422-
binf)
422+
MTSCode._combine_bins_helper("MTS_MDOT_F411RE", binf)
423423

424424
@staticmethod
425425
def combine_bins_mts_dragonfly(t_self, resources, elf, binf):
426426
"""A hoof for the MTS Dragonfly"""
427-
MTSCode._combine_bins_helper("MTS_DRAGONFLY_F411RE", t_self, resources,
428-
elf, binf)
427+
MTSCode._combine_bins_helper("MTS_DRAGONFLY_F411RE", binf)
429428

430429
class MCU_NRF51Code(object):
431430
"""NRF51 Hooks"""
432431
@staticmethod
433-
def binary_hook(t_self, resources, elf, binf):
432+
def binary_hook(t_self, resources, _, binf):
434433
"""Hook that merges the soft device with the bin file"""
435434
# Scan to find the actual paths of soft device
436435
sdf = None
@@ -519,9 +518,9 @@ def set_targets_json_location(location=None):
519518
# re-initialization does not create new variables, it keeps the old ones
520519
# instead. This ensures compatibility with code that does
521520
# "from tools.targets import TARGET_NAMES"
522-
TARGETS[:] = [Target.get_target(name) for name, value
521+
TARGETS[:] = [Target.get_target(target) for target, obj
523522
in Target.get_json_target_data().items()
524-
if value.get("public", True)]
523+
if obj.get("public", True)]
525524
TARGET_MAP.clear()
526525
TARGET_MAP.update(dict([(target.name, target) for target in TARGETS]))
527526
TARGET_NAMES[:] = TARGET_MAP.keys()

0 commit comments

Comments
 (0)