# 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
    There are two possibilites to give input for this method:

    1) use :code:`raw` argument and pass a dictionary containing the keys
    :code:`name`, :code:`nodes` and :code:`edges`.
    This can be created using :func:`method2dot`.
    2) give a :class:`~androguard.core.analysis.analysis.MethodAnalysis`.

    This function requires pydot!

    There is a special format :code:`raw` which saves the dot buffer before it
    is handled by pydot.

    :param str output: output filename
    :param str _format: format type (png, jpg ...). Can use all formats which are understood by pydot.
    :param androguard.core.analysis.analysis.MethodAnalysis mx: specify the MethodAnalysis object
    :param dict raw: use directly a dot raw buffer if None
    """
    # pydot is optional!

    if raw:
        data = raw
    else:
        data = method2dot(mx)

    buff = """
    digraph {{
        graph [rankdir=TB]
        node [shape=plaintext]

        subgraph cluster_{clustername}

# 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

    There are two possibilites to give input for this method:

    1) use :code:`raw` argument and pass a dictionary containing the keys
    :code:`name`, :code:`nodes` and :code:`edges`.
    This can be created using :func:`method2dot`.
    2) give a :class:`~androguard.core.analysis.analysis.MethodAnalysis`.

    This function requires pydot!

    There is a special format :code:`raw` which saves the dot buffer before it
    is handled by pydot.

    :param str output: output filename
    :param str _format: format type (png, jpg ...). Can use all formats which are understood by pydot.
    :param androguard.core.analysis.analysis.MethodAnalysis mx: specify the MethodAnalysis object
    :param dict raw: use directly a dot raw buffer if None
    """
    # pydot is optional!

    if raw:
        data = raw
    else:
        data = method2dot(mx)

    buff = """
    digraph {{
        graph [rankdir=TB]
        node [shape=plaintext]

        subgraph cluster_{clustername}

        {{