xxd_core¶
- hexrec.xxd.xxd_core(infile=None, outfile=None, autoskip=False, bits=None, cols=None, ebcdic=False, endian=False, groupsize=None, include=False, length=None, linesep=None, offset=None, postscript=False, quadword=False, revert=False, oseek=None, iseek=None, upper_all=False, upper=False, oseek_zeroes=True)[source]¶
Emulation of the xxd utility core.
- Parameters:
infile (str or bytes) – Input data. If
str, it is considered as the input file path. Ifbytes, it is the input byte chunk. IfNone, it reads from the standard input.outfile (str or bytes) – Output data. If
str, it is considered as the output file path. Ifbytes, it is the output byte chunk. IfNone, it writes to the standard output.autoskip (bool) – Toggles autoskip. A single
'*'replaces null lines.bits (bool) – Switches to bits (binary digits) dump, rather than hexdump. This option writes octets as eight digits of ‘1’ and ‘0’ instead of a normal hexadecimal dump. Each line is preceded by a line number in hexadecimal and followed by an ASCII (or EBCDIC) representation. The argument switches
revert,postscript,includedo not work with this mode.cols (int) – Formats
colsoctets per line. Max 256. Defaults: normal 16,include12,postscript30,bits6.ebcdic (bool) – Changes the character encoding in the right-hand column from ASCII to EBCDIC. This does not change the hexadecimal representation. The option is meaningless in combinations with
revert,postscriptorinclude.endian (bool) – Switches to little-endian hexdump. This option treats byte groups as words in little-endian byte order. The default grouping of 4 bytes may be changed using
groupsize. This option only applies to hexdump, leaving the ASCII (or EBCDIC) representation unchanged. The switchesrevert,postscript,includedo not work with this mode.groupsize (int) – Separates the output of every
groupsizebytes (two hex characters or eight bit-digits each) by a whitespace. Specifygroupsize0 to suppress grouping.groupsizedefaults to 2 in normal mode, 4 in little-endian mode and 1 in bits mode. Grouping does not apply topostscriptorinclude.include (bool) – Output in C include file style. A complete static array definition is written (named after the input file), unless reading from standard input.
length (int) – Stops after writing
lengthoctets.linesep (bytes) – Line separator characters. If
None, it defaults toos.linesep.encode().offset (int) – Adds
offsetto the displayed file position.postscript (bool) – Outputs in postscript continuous hexdump style. Also known as plain hexdump style.
quadword (bool) – Uses 64-bit addressing.
revert (bool) – Reverse operation: convert (or patch) hexdump into binary. If not writing to standard output, it writes into its output file without truncating it. Use the combination
revertandpostscriptto read plain hexadecimal dumps without line number information and without a particular column layout. Additional Whitespace and line breaks are allowed anywhere.oseek (int) – When used after
revertreverts withoffsetadded to file positions found in hexdump.iseek (int or str) – Starts at
iseekbytes absolute (or relative) input offset. Withoutiseekoption, it starts at the current file position. The prefix is used to compute the offset.+indicates that the seek is relative to the current input position.-indicates that the seek should be that many characters from the end of the input.+-indicates that the seek should be that many characters before the current stdin file position.upper_all (bool) – Uses upper case hex letters on address and data.
upper (bool) – Uses upper case hex letters on data only.
oseek_zeroes (bool) – Output seeking fills with zeros. Only affects outfile of
bytesparse.base.MutableMemory.
- Returns:
stream – The handle to the output stream.