From 89491fd8bb2e8b0d765f7428b3499f4a67ad9bcb Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys <mitchelh@codeaurora.org> Date: Tue, 14 Oct 2014 10:29:32 -0700 Subject: [PATCH] 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 --- linux-ramdump-parser-v2/parser_util.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/linux-ramdump-parser-v2/parser_util.py b/linux-ramdump-parser-v2/parser_util.py index 786019a..942f1e5 100644 --- a/linux-ramdump-parser-v2/parser_util.py +++ b/linux-ramdump-parser-v2/parser_util.py @@ -180,12 +180,19 @@ def _xxd_line(addr, data): ) def xxd(address, data, file_object=None): - """Dumps data to stdout, in the format of `xxd'. data should be a list - of integers. + """Dumps data to `file_object' or stdout, in the format of `xxd'. data + should be a list of integers. >>> 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 + >>> 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 bb = [] -- GitLab