add size parameter to conversion methods

Bug #408748 reported by Alexander Belchenko
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IntelHex
Fix Released
Medium
Alexander Belchenko

Bug Description

See https://bugs.launchpad.net/intelhex/+bug/372625 for reference.

sneakypete wrote:

To give a quick example:
    for addr in range(0, EEPROM_SIZE, BLOCK_SIZE):
        eeprom.i2c_write(addr, ih.tobinarray(addr, addr + BLOCK_SIZE - 1))

The "-1" is messy, and shouldn't be required (and looks a lot like visual basic!).

I agree, it's messy. We can provide a better API (without API break) by introducing additional size parameter. So the example above will be:

      for addr in range(0, EEPROM_SIZE, BLOCK_SIZE):
          eeprom.i2c_write(addr, ih.tobinarray(start=addr,
                                               size=BLOCK_SIZE))

I think it's more readable.

To avoid API break this new parameter should be added after existing ones, e.g. method signature should be:

    def tobinarray(self, start=None, end=None, pad=None, size=None):

and we have to check that start is not None and end is None when size is not None.

Related branches

Changed in intelhex:
importance: Undecided → Medium
status: New → Confirmed
Changed in intelhex:
milestone: none → 1.3
Changed in intelhex:
status: Confirmed → Fix Released
Changed in intelhex:
assignee: nobody → Alexander Belchenko (bialix)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.