ó
a#nSc           @   sF   d  Z  d d l Z d d l Z e j Z d d d d  Z d   Z d S(   s  
$Id$

Original author:  Thorsten Henninger <henni@brainbot.com>
Info about this file: http://mail.python.org/pipermail/python-win32/2003-December/001453.html

Use this in confuction with McMillan-Installer, if you need COM-Support in your application.
McMillan Installer as well as PythonCOM do overwrite the import Method for their needs.

_myimport advises the imports to either PythonCOM-Import or McMillan Import.

set_gen_path: use this method to specify the gencache-path, where all Python-COMObjects will be
              automatically generated in.

One needs to Patch the McMillan Installer such that the Python-nativ import has to be saved as
__oldimport__

Use this hack in your application with

import comhack
set_gen_path(mypath)

Then everything will work ...
i˙˙˙˙Nc         C   sY   y t  |  | | |  SWn; t k
 rT } |  j d  rK t |  | | |  S|  n Xd S(   s   
    Tell all modules to imported by McMillan's (or Python's) import.method,
    besides win32com modules automatically genrated by win32com.gencache
    s   win32com.gen_pyN(   t   mcimportt   ImportErrort
   startswitht   __oldimport__(   t   namet   globalst   localst   fromlistt   err(    (    sU   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/utils/comhack.pyt	   _myimport    s    c         C   s   d d l  } d d l } d d l } | j j |   }  | j j |   sX | j |   n  t j j	 d d  } |  g | j
 _ |  | _ | s d St t _ d S(   s   
    Set the gencache Path
    If not set, all Modules (win32com) will be generated to support/gen_py of your apllication.
    i˙˙˙˙Nt   frozeni    (   t   ost   win32comt   win32com.gen_pyt   patht   abspatht   existst   makedirst   syst   __dict__t   gett   gen_pyt   __path__t   __gen_path__R	   t   __builtin__t
   __import__(   R   R   R   R
   (    (    sU   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/utils/comhack.pyt   set_gen_path2   s    	(   t   __doc__R   R   R   R    t   NoneR	   R   (    (    (    sU   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/utils/comhack.pyt   <module>   s
   	