added Bin() to format_hints: print the value as a Python binary number

This commit is contained in:
Nick L. Petroni, Jr
2017-04-17 14:05:50 -04:00
parent 0f9dbe3112
commit f05df0c1cd
2 changed files with 5 additions and 1 deletions
@@ -5,6 +5,9 @@ These hints allow a plugin to indicate how they'd like a particular column's dat
Text renderers should attempt to honour all hints provided in this module where possible
"""
class Bin(int):
"""A class to indicate that the integer value should be represented as a binary value"""
class Hex(int):
"""A class to indicate that the integer value should be represented as a hexidecimal value"""
+2 -1
View File
@@ -25,7 +25,8 @@ def hex_bytes_as_text(value):
class QuickTextRenderer(interfaces.renderers.Renderer):
type_renderers = {format_hints.Hex: lambda x: "{:x}".format(x),
type_renderers = {format_hints.Bin: lambda x: "{:b}".format(x),
format_hints.Hex: lambda x: "{:x}".format(x),
format_hints.HexBytes: hex_bytes_as_text,
bytes: lambda x: x.decode("utf-8"),
'default': lambda x: "{}".format(x)}