Skip to content
Snippets Groups Projects
Commit 89491fd8 authored by Mitchel Humpherys's avatar Mitchel Humpherys
Browse files

lrdpv2: parser_util: improve xxd docstring

The `file_object' parameter is undocumented and doesn't have a doctest.
Add documentation and a doctest.

Change-Id: Ifc259948c8280c94fcf34046959b1a3709c8b470
parent 847d7022
No related branches found
No related tags found
No related merge requests found
...@@ -180,12 +180,19 @@ def _xxd_line(addr, data): ...@@ -180,12 +180,19 @@ def _xxd_line(addr, data):
) )
def xxd(address, data, file_object=None): def xxd(address, data, file_object=None):
"""Dumps data to stdout, in the format of `xxd'. data should be a list """Dumps data to `file_object' or stdout, in the format of `xxd'. data
of integers. should be a list of integers.
>>> xxd(0x1000, [0xde, 0xad, 0xbe, 0xef, 112, 105, 122, 122, 97, 0, 0, 42, 43, 44, 45, 90]) >>> xxd(0x1000, [0xde, 0xad, 0xbe, 0xef, 112, 105, 122, 122, 97, 0, 0, 42, 43, 44, 45, 90])
00001000: dead beef 7069 7a7a 6100 002a 2b2c 2d5a ....pizza..*+,-Z 00001000: dead beef 7069 7a7a 6100 002a 2b2c 2d5a ....pizza..*+,-Z
>>> import StringIO
>>> sio = StringIO.StringIO()
>>> xxd(0x400, range(45, 76), sio)
>>> print(sio.getvalue().strip())
00000400: 2d2e 2f30 3132 3334 3536 3738 393a 3b3c -./0123456789:;<
00000410: 3d3e 3f40 4142 4344 4546 4748 494a 4b =>?@ABCDEFGHIJK
""" """
f = file_object or sys.stdout f = file_object or sys.stdout
bb = [] bb = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment