
    M@c	                     :    d dl Z d dlZd dlmZ dZ G d de      Zy)    N)LoaderPluginzeyeD3mod.pyc                   X     e Zd ZdZde dZdgZ fdZd Z fdZ	 fdZ
 fd	Z xZS )
PyModulePluginzWImports a Python module file and calls its functions for the the various plugin events.z'
If no module if provided a file named aO   in the current working directory is
imported. If any of the following methods exist they still be invoked:

def audioFile(audio_file):
    """Invoked for every audio file that is encountered. The ``audio_file``
    is of type ``eyed3.core.AudioFile``; currently this is the concrete type
    ``eyed3.mp3.Mp3AudioFile``."""
    pass

def audioDir(d, audio_files, images):
    """This function is invoked for any directory (``d``) that contains audio
    (``audio_files``) or image (``images``) media."""
    pass

def done():
    """This method is invoke before successful exit."""
    pass
pymodc                     t         t        |   |dd       d | _        | j                  j                  ddddt                y )NT)cache_filestrack_imagesz-mz--modulemodulez5The Python module module to invoke. The default is ./)desthelp)superr   __init___mod	arg_groupadd_argument_DEFAULT_MOD)self
arg_parser	__class__s     5/usr/lib/python3/dist-packages/eyed3/plugins/pymod.pyr   zPyModulePlugin.__init__    sT    nd,ZT:> 	- 	@	##D*8*==IN*L 	$ 	M    c                    |j                   xs t        }	 t        j                  j	                  t        j                  j                  |            d   }t        j                  j                  ||      }|j                         }|| _
        y # t        $ r t        d|z        t        t        t        f$ r}t        dt        |      z        d }~ww xY w)Nr   zModule file not found: %szModule load error: %s)r
   r   ospathsplitextbasename	importlib	machinerySourceFileLoaderload_moduler   IOError	NameErrorImportErrorSyntaxErrorstr)r   argsconfigmod_filemod_nameloadermodexs           r   startzPyModulePlugin.start(   s    ;;.,	=ww''(8(8(BCAFH((99(HMF$$&CDI 	B5@AA;4 	=1CG;<<	=s   A6B *C7CCc                     t         t        |   |       | j                  sy dt	        | j
                        v r&| j
                  j                  | j                         y y )N	audioFile)r   r   
handleFile
audio_filedirr   r/   )r   fr   s     r   r0   zPyModulePlugin.handleFile4   sG    nd.q1#dii.(II0 )r   c                     | j                   s| j                  sy dt        | j                        v r1| j                  j	                  || j                   | j                         t
        t        |   ||       y )NaudioDir)_file_cache_dir_imagesr2   r   r5   r   r   handleDirectory)r   d_r   s      r   r8   zPyModulePlugin.handleDirectory<   sZ    (8(8TYY'IIq$"2"2D4D4DEnd3Aq9r   c                     t         t        |           dt        | j                        v r| j                  j                          y y )Ndone)r   r   
handleDoner2   r   r<   )r   r   s    r   r=   zPyModulePlugin.handleDoneE   s3    nd.0S^#IINN $r   )__name__
__module____qualname__SUMMARYr   DESCRIPTIONNAMESr   r-   r0   r8   r=   __classcell__)r   s   @r   r   r      sH    +G''3n 5K& IEM
=1: r   r   )r   importlib.machineryr   eyed3.pluginsr   r   r    r   r   <module>rH      s!    	  &@\ @r   