ó
[³XMc           @   sN   d  Z  d d l m Z d d l Z d d l Z d „  Z d d d „  ƒ  YZ d S(   s4   Creation of  Windows shortcuts.

Requires win32all.
iÿÿÿÿ(   t   shellNc         C   s   t  ƒ  } | j |  ƒ | S(   sb   Open an existing shortcut for reading.

    @return: The shortcut object
    @rtype: Shortcut
    (   t   Shortcutt   load(   t   filenamet   sc(    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/shortcut.pyt   open   s    	R   c           B   sD   e  Z d  Z d d d d d d d „ Z d „  Z d „  Z d „  Z RS(   s  A shortcut on Win32.
    >>> sc=Shortcut(path, arguments, description, workingdir, iconpath, iconidx)
    @param path: Location of the target
    @param arguments: If path points to an executable, optional arguments to
                      pass
    @param description: Human-readable decription of target
    @param workingdir: Directory from which target is launched
    @param iconpath: Filename that contains an icon for the shortcut
    @param iconidx: If iconpath is set, optional index of the icon desired
    i    c   
      C   sÃ   t  j t j d  t  j t j ƒ |  _ t d  d t	 j
 j | ƒ | | t	 j
 j | ƒ t	 j
 j | ƒ g d ƒ } x6 | D]. \ } }	 | rt |	 rt t |  |	 ƒ | ƒ qt qt W| r¿ |  j | | ƒ n  d  S(   Ns   "%s"t   SetPatht   SetArgumentst   SetDescriptiont   SetWorkingDirectory(   R   R   R   R	   (   t	   pythoncomt   CoCreateInstanceR    t   CLSID_ShellLinkt   Nonet   CLSCTX_INPROC_SERVERt   IID_IShellLinkt   _baset   mapt   ost   patht   abspatht   getattrt   SetIconLocation(
   t   selfR   t	   argumentst   descriptiont
   workingdirt   iconpatht   iconidxt   datat   valuet   function(    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/shortcut.pyt   __init__&   s    	! 	c         C   s    |  j  j t j ƒ j | ƒ d S(   s   Read a shortcut file from disk.N(   R   t   QueryInterfaceR
   t   IID_IPersistFilet   Load(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/shortcut.pyR   =   s    c         C   s#   |  j  j t j ƒ j | d ƒ d S(   sU   Write the shortcut to disk.

        The file should be named something.lnk.
        i    N(   R   R!   R
   R"   t   Save(   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/shortcut.pyt   saveA   s    c         C   s9   | d k r t  |  j | ƒ St d |  j j | f ‚ d  S(   NR   s   %s instance has no attribute %s(   R   R   t   AttributeErrort	   __class__t   __name__(   R   t   name(    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/shortcut.pyt   __getattr__H   s    N(   R(   t
   __module__t   __doc__R   R    R   R%   R*   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/shortcut.pyR      s   
		(    (   R,   t   win32com.shellR    R
   R   R   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/twisted/python/shortcut.pyt   <module>   s
   	