Skip to content

Commit 858a7a8

Browse files
Naveen KajeNaveen Kaje
authored andcommitted
tools: Update build_api
Rename loop varibles for better readability and formatting changes.
1 parent bd40457 commit 858a7a8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

tools/build_api.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -435,23 +435,22 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
435435
# this is only to get a neat ToolException anyway, since IntelHex.merge will
436436
# throw IntelHex.AddressOverlapError if there's overlapping
437437
part_size = 0
438-
for es in part.segments():
439-
part_size += es[1] - es[0]
440-
merged.merge(part[es[0]:_end_addr_inclusive(es[1])])
438+
for start, stop in part.segments():
439+
part_size += stop - start
440+
merged.merge(part)
441441

442442
if part_size > region.size:
443443
raise ToolException("Contents of region %s does not fit"
444444
% region.name)
445445

446446
# Hex file can have gaps, so no padding needed. While other formats may
447447
# need padding. Iterate through segments and pad the gaps.
448-
if (format != ".hex"):
448+
if format != ".hex":
449449
begin = 0
450-
for es in merged.segments():
451-
if (begin < es[0]):
452-
pad_size = es[0] - begin
453-
merged.puts(begin, padding * pad_size)
454-
begin = es[1] + 1
450+
for start, stop in merged.segments():
451+
pad_size = start - begin
452+
merged.puts(begin, padding * pad_size)
453+
begin = stop + 1
455454

456455
if not exists(dirname(destination)):
457456
makedirs(dirname(destination))

0 commit comments

Comments
 (0)