# Path: androguard/core/androconf.py
# CONF = Configuration()
# 
# def color_range(startcolor, goalcolor, steps):
#     """
#     wrapper for interpolate_tuple that accepts colors as html ("#CCCCC" and such)
#     """
#     start_tuple = make_color_tuple(startcolor)
#     goal_tuple = make_color_tuple(goalcolor)
# 
#     return interpolate_tuple(start_tuple, goal_tuple, steps)
# 
# Path: androguard/core/bytecodes/dvm_types.py
# class Kind(IntEnum):
#     """
#     This Enum is used to determine the kind of argument
#     inside an Dalvik instruction.
# 
#     It is used to reference the actual item instead of the refernece index
#     from the :class:`ClassManager` when disassembling the bytecode.
#     """
#     # Indicates a method reference
#     METH = 0
#     # Indicates that opcode argument is a string index
#     STRING = 1
#     # Indicates a field reference
#     FIELD = 2
#     # Indicates a type reference
#     TYPE = 3
#     # indicates a prototype reference
#     PROTO = 9
#     # indicates method reference and proto reference (invoke-polymorphic)
#     METH_PROTO = 10
#     # indicates call site item
#     CALL_SITE = 11
# 
#     # TODO: not very well documented
#     VARIES = 4
#     # inline lined stuff
#     INLINE_METHOD = 5
#     # static linked stuff
#     VTABLE_OFFSET = 6
#     FIELD_OFFSET = 7
#     RAW_STRING = 8
# 
# class Operand(IntEnum):
#     """
#     Enumeration used for the operand type of opcodes
#     """
#     REGISTER = 0
#     LITERAL = 1
#     RAW = 2
#     OFFSET = 3
#     # FIXME: KIND is used in combination with others, ie the Kind enum, therefore it is 0x100...
#     # thus we could use an IntFlag here as well
#     KIND = 0x100


import hashlib
import textwrap
import json
import logging
    import pydot
from xml.sax.saxutils import escape
from struct import pack
from androguard.core.androconf import CONF, color_range
from androguard.core.bytecodes.dvm_types import Kind, Operand
            "idx": "blue",
            "bg_start_idx": "yellow",
            "bg_instruction": "lightgray",
            "instruction_name": "black",
            "instructions_operands": "yellow",
            "raw": "red",
            "string": "red",
            "literal": "green",
            "offset": "#4000FF",
            "method": "#DF3A01",
            "field": "#088A08",
            "type": "#0000FF",
            "registers_range": ("#999933", "#6666FF")
        }

    node_tpl = """
    struct_%s [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="3">
            %s
        </TABLE>
    >];
    """
    label_tpl = """
    <TR>
        <TD ALIGN="LEFT" BGCOLOR="%s">
            <FONT FACE="{font_face}" color="%s">%04x</FONT>
        </TD>
        <TD ALIGN="LEFT" BGCOLOR="%s">
            <FONT FACE="{font_face}" color="%s">%s</FONT> %s
        </TD>

# Path: androguard/core/androconf.py
# CONF = Configuration()
# 
# def color_range(startcolor, goalcolor, steps):
#     """
#     wrapper for interpolate_tuple that accepts colors as html ("#CCCCC" and such)
#     """
#     start_tuple = make_color_tuple(startcolor)
#     goal_tuple = make_color_tuple(goalcolor)
# 
#     return interpolate_tuple(start_tuple, goal_tuple, steps)
# 
# Path: androguard/core/bytecodes/dvm_types.py
# class Kind(IntEnum):
#     """
#     This Enum is used to determine the kind of argument
#     inside an Dalvik instruction.
# 
#     It is used to reference the actual item instead of the refernece index
#     from the :class:`ClassManager` when disassembling the bytecode.
#     """
#     # Indicates a method reference
#     METH = 0
#     # Indicates that opcode argument is a string index
#     STRING = 1
#     # Indicates a field reference
#     FIELD = 2
#     # Indicates a type reference
#     TYPE = 3
#     # indicates a prototype reference
#     PROTO = 9
#     # indicates method reference and proto reference (invoke-polymorphic)
#     METH_PROTO = 10
#     # indicates call site item
#     CALL_SITE = 11
# 
#     # TODO: not very well documented
#     VARIES = 4
#     # inline lined stuff
#     INLINE_METHOD = 5
#     # static linked stuff
#     VTABLE_OFFSET = 6
#     FIELD_OFFSET = 7
#     RAW_STRING = 8
# 
# class Operand(IntEnum):
#     """
#     Enumeration used for the operand type of opcodes
#     """
#     REGISTER = 0
#     LITERAL = 1
#     RAW = 2
#     OFFSET = 3
#     # FIXME: KIND is used in combination with others, ie the Kind enum, therefore it is 0x100...
#     # thus we could use an IntFlag here as well
#     KIND = 0x100


# Path: androguard/core/bytecode.py
import hashlib
import textwrap
import json
import logging
    import pydot
from xml.sax.saxutils import escape
from struct import pack
from androguard.core.androconf import CONF, color_range
from androguard.core.bytecodes.dvm_types import Kind, Operand

            "idx": "blue",
            "bg_start_idx": "yellow",
            "bg_instruction": "lightgray",
            "instruction_name": "black",
            "instructions_operands": "yellow",
            "raw": "red",
            "string": "red",
            "literal": "green",
            "offset": "#4000FF",
            "method": "#DF3A01",
            "field": "#088A08",
            "type": "#0000FF",
            "registers_range": ("#999933", "#6666FF")
        }

    node_tpl = """
    struct_%s [label=<
        <TABLE BORDER="0" CELLBORDER="0" CELLSPACING="3">
            %s
        </TABLE>
    >];
    """
    label_tpl = """
    <TR>
        <TD ALIGN="LEFT" BGCOLOR="%s">
            <FONT FACE="{font_face}" color="%s">%04x</FONT>
        </TD>
        <TD ALIGN="LEFT" BGCOLOR="%s">
            <FONT FACE="{font_face}" color="%s">%s</FONT> %s
        </TD>

    </TR>