def find_graphviz():
<EOL>if os.sys.platform == '<STR_LIT:win32>':<EOL><INDENT>HKEY_LOCAL_MACHINE =    <NUM_LIT><EOL>KEY_QUERY_VALUE =       <NUM_LIT><EOL>RegOpenKeyEx = None<EOL>RegQueryValueEx = None<EOL>RegCloseKey = None<EOL>try:<EOL><INDENT>import win32api, win32con<EOL>RegOpenKeyEx = win32api.RegOpenKeyEx<EOL>RegQueryValueEx = win32api.RegQueryValueEx<EOL>RegCloseKey = win32api.RegCloseKey<EOL><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>import ctypes<EOL>def RegOpenKeyEx(key, subkey, opt, sam):<EOL><INDENT>result = ctypes.c_uint(<NUM_LIT:0>)<EOL>ctypes.windll.advapi32.RegOpenKeyExA(key, subkey, opt, sam, ctypes.byref(result))<EOL>return result.value<EOL><DEDENT>def RegQueryValueEx( hkey, valuename ):<EOL><INDENT>data_type = ctypes.c_uint(<NUM_LIT:0>)<EOL>data_len = ctypes.c_uint(<NUM_LIT>)<EOL>data = ctypes.create_string_buffer( <NUM_LIT> )<EOL>res = ctypes.windll.advapi32.RegQueryValueExA(hkey, valuename, <NUM_LIT:0>, <EOL>ctypes.byref(data_type), data, ctypes.byref(data_len))<EOL>return data.value<EOL><DEDENT>RegCloseKey = ctypes.windll.advapi32.RegCloseKey<EOL><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT>if RegOpenKeyEx is not None:<EOL><INDENT>hkey = None<EOL>potentialKeys = [<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>]<EOL>for potentialKey in potentialKeys:<EOL><INDENT>try:<EOL><INDENT>hkey = RegOpenKeyEx( HKEY_LOCAL_MACHINE,<EOL>potentialKey, <NUM_LIT:0>, KEY_QUERY_VALUE )<EOL>if hkey is not None:<EOL><INDENT>path = RegQueryValueEx( hkey, "<STR_LIT>" )<EOL>RegCloseKey( hkey )<EOL>if not path:<EOL><INDENT>continue<EOL><DEDENT>path = os.path.join(path, "<STR_LIT>")<EOL>progs = __find_executables(path)<EOL>if progs is not None :<EOL><INDENT>return progs<EOL><DEDENT><DEDENT><DEDENT>except Exception as excp:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if '<STR_LIT>' in os.environ:<EOL><INDENT>for path in os.environ['<STR_LIT>'].split(os.pathsep):<EOL><INDENT>progs = __find_executables(path)<EOL>if progs is not None :<EOL><INDENT>return progs<EOL><DEDENT><DEDENT><DEDENT>if os.sys.platform == '<STR_LIT:win32>':<EOL><INDENT>if '<STR_LIT>' in os.environ:<EOL><INDENT>path = os.path.join(os.environ['<STR_LIT>'], '<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>path = r"<STR_LIT>"<EOL><DEDENT>progs = __find_executables(path)<EOL>if progs is not None :<EOL><INDENT>return progs<EOL><DEDENT><DEDENT>for path in (<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>' ):<EOL><INDENT>progs = __find_executables(path)<EOL>if progs is not None :<EOL><INDENT>return progs<EOL><DEDENT><DEDENT>return None<EOL>
Locate Graphviz's executables in the system.

    Tries three methods:

    First: Windows Registry (Windows only)
    This requires Mark Hammond's pywin32 is installed.

    Secondly: Search the path
    It will look for 'dot', 'twopi' and 'neato' in all the directories
    specified in the PATH environment variable.

    Thirdly: Default install location (Windows only)
    It will look for 'dot', 'twopi' and 'neato' in the default install
    location under the "Program Files" directory.

    It will return a dictionary containing the program names as keys
    and their paths as values.

    If this fails, it returns None.