U
    ¸~Hjî  ã                   @   s:   d Z ddlZddlZddlmZ dd„ ZG dd„ dƒZdS )z5
Creation of  Windows shortcuts.

Requires win32all.
é    N)Úshellc                 C   s   t ƒ }| | ¡ |S )zg
    Open an existing shortcut for reading.

    @return: The shortcut object
    @rtype: Shortcut
    )ÚShortcutÚload)ÚfilenameZsc© r   ú;/tmp/pip-unpacked-wheel-ewod1tgb/twisted/python/shortcut.pyÚopen   s    
r   c                   @   s2   e Zd ZdZddd„Zdd„ Zdd	„ Zd
d„ ZdS )r   z
    A shortcut on Win32.
    Nr   c                 C   s�   t  tjdt jtj¡| _|dk	r2|  tj	 
|¡¡ |dk	rD|  |¡ |dk	rV|  |¡ |dk	rp|  tj	 
|¡¡ |dk	rŒ|  tj	 
|¡|¡ dS )a½  
        @param path: Location of the target
        @param arguments: If path points to an executable, optional arguments
                      to pass
        @param description: Human-readable description 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
        N)Ú	pythoncomZCoCreateInstancer   ZCLSID_ShellLinkZCLSCTX_INPROC_SERVERZIID_IShellLinkÚ_baseZSetPathÚosÚpathÚabspathZSetArgumentsZSetDescriptionZSetWorkingDirectoryZSetIconLocation)Úselfr   Ú	argumentsÚdescriptionZ
workingdirZiconpathZiconidxr   r   r   Ú__init__"   s     ü

zShortcut.__init__c                 C   s    | j  tj¡ tj |¡¡ dS )z1
        Read a shortcut file from disk.
        N)r
   ÚQueryInterfacer	   ÚIID_IPersistFileÚLoadr   r   r   ©r   r   r   r   r   r   E   s    
ÿzShortcut.loadc                 C   s"   | j  tj¡ tj |¡d¡ dS )z^
        Write the shortcut to disk.

        The file should be named something.lnk.
        r   N)r
   r   r	   r   ZSaver   r   r   r   r   r   r   ÚsaveM   s    
 ÿzShortcut.savec                 C   s   t | j|ƒS )N)Úgetattrr
   )r   Únamer   r   r   Ú__getattr__W   s    zShortcut.__getattr__)NNNNNr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s         ù
#
r   )r   r   r	   Úwin32com.shellr   r   r   r   r   r   r   Ú<module>   s
   