iotile / typedargs

API typechecking and command line shell generation package
GNU Lesser General Public License v3.0
1 stars 2 forks source link

Add support for hex and hexdump formatting of bytes types. #55

Closed timburke closed 5 years ago

timburke commented 5 years ago

This will allow the creation of docannotate function signatures such as:

@docannotate
def read_binary_data():
    """Read some binary data that cannot be easily printed as a string.

    Returns:
        bytes format-as hexdump: The binary data that we read.
    """

That annotation will pass back binary data to the user as bytes when called from python but if invoked directly from the python shell using e.g. the iotile tool in CoreTools, it will print a hex representation of the binary string instead. For functions that expect to generate a large amount of binary data, you can use format-as hexdump instead which will generate a nice hex dump with address offset, structured hex formatting and ascii conversion.

Closes #54