Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
Signed-off-by: TexZK <[email protected]>
  • Loading branch information
TexZK committed Nov 9, 2023
1 parent 0958e71 commit fc4440e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ graft .github
graft docs
graft src
graft tests
graft _static
graft pyinstaller

include .coveragerc
Expand Down
19 changes: 9 additions & 10 deletions src/hexrec/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def blocks_to_records(


def merge_records(
data_records: Sequence[RecordSequence],
records: Sequence[RecordSequence],
input_types: Optional[Sequence[type]] = None,
output_type: Optional[RecordType] = None,
split_args: Optional[Sequence[Any]] = None,
Expand All @@ -275,10 +275,11 @@ def merge_records(
overlapping data of the previous sequences.
Arguments:
data_records (list of records):
A vector of *data* record sequences.
records (list of records):
A vector of record sequences.
If `input_types` is not ``None``, sequence generators are
supported for the vector and its nested sequences.
Only *data* records are kept.
input_types (list of types):
Selects the record type for each of the sequences in
Expand Down Expand Up @@ -317,25 +318,23 @@ def merge_records(
>>> records1 = blocks_to_records(blocks1, MotorolaRecord)
>>> records2 = blocks_to_records(blocks2, IntelRecord)
>>> IntelRecord.readdress(records2)
>>> data_records1 = get_data_records(records1)
>>> data_records2 = get_data_records(records2)
>>> merged_records = merge_records([data_records1, data_records2])
>>> merged_records = merge_records([records1, records2])
>>> merged_blocks = records_to_blocks(merged_records)
>>> merged_blocks == Memory.collapse_blocks(blocks1 + blocks2)
True
"""
if input_types is None:
input_types = [type(records[0]) if records else Record
for records in data_records]
input_types = [type(subrecords[0]) if subrecords else Record
for subrecords in records]
else:
input_types = list(input_types)

if output_type is None:
output_type = input_types[0]

blocks = []
for records in data_records:
blocks.extend([r.address, r.data] for r in records if r.is_data())
for subrecords in records:
blocks.extend([r.address, r.data] for r in subrecords if r.is_data())
blocks = Memory.collapse_blocks(blocks)

output_records = blocks_to_records(blocks, output_type,
Expand Down

0 comments on commit fc4440e

Please sign in to comment.