U
    
W[                     @   s:   d Z ddlmZ ddlZddlZdd ZG dd dZdS )z5
Creation of  Windows shortcuts.

Requires win32all.
    )shellNc                 C   s   t  }||  |S )zg
    Open an existing shortcut for reading.

    @return: The shortcut object
    @rtype: Shortcut
    )Shortcutload)filenameZsc r   9/usr/lib/python3/dist-packages/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   Z	argumentsZ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_IPersistFileZLoadr   r   r   r   r   r   r   r   r   B   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   saveJ   s    
 zShortcut.savec                 C   s   t | j|S )N)getattrr
   )r   namer   r   r   __getattr__T   s    zShortcut.__getattr__)NNNNNr   )__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r      s         
 
r   )r   Zwin32com.shellr   r	   r   r   r   r   r   r   r   <module>   s
   