
    M@c*                         d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z
 d dlZd dlZd dlZd dlZd dlZd dlmZ dZe j&                  j)                  d      Ze j&                  j)                  d      Ze j&                  j)                  d	      Ze j&                  j)                  d
      Zd Zd Z ej6                  ddej8                  j:                  de       d        Zd Zd Z d Z!	 	 ddZ"ddZ#ddZ$d Z%e&dk(  r e%        yy)    N)StringIO)ConfigParser)Error)initLoggingclassicz ${HOME}/.config/eyeD3/config.iniz${HOME}/.config/eyeD3/pluginsz${HOME}/.eyeD3/config.iniz${HOME}/.eyeD3/pluginsc                    d| v r| j                   rt        |       y| j                  j                  | |       d}d| v r| j                   }nd| v r| j
                  }| j                  D ]D  }t        j                  j                  | j                  || j                  | j                  |       F | j                  j                         }|xs dS )Nlist_pluginsr   Fnon_recursive	recursive)excludesfs_encodingr   )r	   _listPluginspluginstartr
   r   pathseyed3utilswalkr   r   
handleDone)argsconfigr   pretvals        ,/usr/lib/python3/dist-packages/eyed3/main.pymainr      s    $"3"3VKKdF#I$***			NN	 ZZ .a$--TM]M]#, 	 	.. [[##%F;Q    c                 n  	 ddl mm	 	fd}t        j                  j                  dt        |             }g }t        |j                               D ]   }|j                  |j                  d          " t        d       |j                          |D ]  }||   }|j                  dd  }|rdd	j                  |       d
nd}t         ||       d| d       t        j                  |j                   dd      D ]'  }t        j"                   | 	j$                          ) t        d        y )Nr   )ForeStylec                 v    | t         k(  }j                  |rj                  ndz   dz   | z   j                  z   S )N z* )DEFAULT_PLUGINBRIGHTGREEN	RESET_ALL)name
is_defaultr   r   s     r   headerz_listPlugins.<locals>.header4   s?    ^+
j

bADH' 	(r   T)reloadr   z3
Type 'eyeD3 --plugin=<name> --help' for more help
   z (z, )r!    :z  )initial_indentsubsequent_indent)eyed3.utils.consoler   r   r   pluginsload_getPluginPathsetvaluesappendNAMESprintsortjointextwrapwrapSUMMARYYELLOWr%   )
r   r(   all_pluginsplugin_namesr   r&   	alt_namestxtr   r   s
           @@r   r   r   1   s   /(
 --$$Dv8N$OKLk((*+ -FLLO,- 

AB 	T"LL$	4=b9-.a02	a	{!,-==[bc 	:CT[[M#u&789	:b		r   z0.9a2z1.0zDefault eyeD3 config moved to )deprecated_in
removed_incurrent_versiondetailsc                      y)zThis here to add deprecation.N )_s    r   _deprecatedConfigFileCheckrJ   N   s    r   c                 \   g }| j                   r8|j                  t        j                  j	                  | j                                | j
                  du r*|j                  t               |j                  t               |sy |D ]m  }t        j                  j                  |      r+t        |       	 t               }|j                  |       |c S |t        k7  sW|t        k7  sat!        d|        y # t        $ r-}t        j                  j                  d|        Y d }~ y d }~ww xY w)NFzUser config error: zUser config not found: )r   r6   ospathabspath	no_configDEFAULT_CONFIGDEFAULT_CONFIG_DEPRECATEDisfilerJ   r   readConfigParserErrorr   logwarningIOError)r   config_filesconfig_filer   exs        r   _loadConfigr[   U   s    L{{BGGOODKK89~~N+56# C77>>+&&{3%K(
 N*{>W/W3K=ABBC % 		!!$7t"<=s   2C55	D+>"D&&D+c           	      &   t         g}| r| j                  dd      rp| j                  dd      }||j                  d      D cg c]@  }|r<t        j
                  j                  t        j
                  j                  |            B c}z  }|S c c}w )Ndefaultplugin_pathr-   )USER_PLUGINS_DIR
has_optiongetsplitrL   rM   
expanduser
expandvars)r   r^   valds       r   r3   r3   r   s    #$K&##I}=jjM2"yy~6a14 **277+=+=a+@A 6 	66s   ABc                    ddl }ddl}t        j                  j	                  d       |j                         }|j                  dt               t                     }t               }|j                  ||      }|j                  d       |j                  d       |j                          |j                          t        j                   j#                  d|j%                         z         y)	zoThis is the main function for profiling
    http://code.google.com/appengine/kb/commontasks.html#profiling
    r   Nzdriver profileMainz
main(args))streamtimed   zProfile data:
%s
)cProfilepstatsr   rU   debugProfilerunctxglobalslocalsr   Stats
sort_statsprint_statsprint_calleesprint_callerssysstderrwritegetvalue)r   r   rk   rl   profrh   statss          r   profileMainr}   |   s     	IIOO()D;;|WY9DZFLLfL-E	V	c 
	JJ*V__->>?r   c           
      *   |du r| j                  ddddd       n| j                  dd	dd
d       | j                  ddddd       | j                  dddt        j                  ddt        j                   d       | j                  d|d|       y )NFz-rz--recursive
store_truer   zRecurse into subdirectories.actiondesthelpz-Rz--non-recursiver
   z#Do not recurse into subdirectories.z	--excluder6   PATTERNr   zIA regular expression for path exclusion. May be specified multiple times.)r   metavarr   r   z--fs-encodingstorer   ENCODINGzUUse the specified file system encoding for filenames. Default as it was detected is 'zI' but this option is still useful when reading from mounted file systems.r   r   r]   r   r   r   *)r   nargsr   )add_argumentr   LOCAL_FS_ENCODING)
arg_parserdefault_recursivepaths_metavar
paths_helps       r   setFileScannerOptsr      s     E!mL{%C 	  	E 	&7Sb%J 	  	L K)R\"3  4 OG-$)$;$;Z"CCHCZCZB[ \,",  - G]#JWr   c                    ddl m} | s" |t        j                  j                  d      n| }t        |       |j                  ddddd	d
       |j                  ddddd ddt         d       |j                  ddddd ddt         d       |j                  dddd       |j                  dddd dd!"       |j                  d#dd$d%       |j                  d&dd'd(t         d)       |S )*Nr   )ArgumentParserT)progadd_helpz-Lz	--pluginsr   Fr	   zList all available plugins)r   r]   r   r   -P--pluginr   r   NAMEz-Specify which plugin to use. The default is ''r   -C--configr   FILEz-Supply a configuration file. The default is 'z"', although even that is optional.z--backupbackupzPlugins should honor this option such that a backup is made of any file modified. The backup is made in same directory with a '.orig' extension added.r   z-Qz--quietquietz!A hint to plugins to output less.)r   r   r]   r   z
--no-colorno_colorzSuppress color codes in console output. This will happen automatically if the output is not a TTY (e.g. when redirecting to a file)--no-configrO   z%Do not load the default user config 'z8'. The -c/--config options are still honored if present.)	eyed3.utilsr   r   	__about____project_name__r   r   r"   rP   )	subparserr   r   s      r   makeCmdLineParserr      sI   *  	EOO<<tL"+  qNN4\5&-I  KNN4G(GGWWXY  [ NN4G(*++MO  P NN:l+  ,
 NN4<g 'J  LNN<:F  G NN=&[??O PP P  Q
 Hr   c                 P   | rt        |       nt        t        j                  dd        } g }d\  }}|t        |       k  r| |   }|r|j	                  |       d}|dv r|j	                  |       |dk7  rXd}nU|j                  d      s3|j                  d      s"|j                  d	      s|j                  d
      r|j	                  |       |dz  }|t        |       k  rt               }|j                  |      }t        |      }|j                  r|j                  }n5|r-|j                  dd      r|j                  dd      }|st        }nt        }t        j                  j                  |t!        |            }	|	=t        j"                  j$                  j'                  d|z         |j)                  d        |	|      }
|rA|j                  dd      r/| j+                  |j                  dd      j-                                |rA|j                  |d      r/| j+                  |j                  |d      j-                                |j                  |       }|
|_	        t        j.                  j1                  d|       t        j.                  j1                  d|
       |||fS )Nr*   )r   FF)r   r   r   r   r   r   Tz-C=z	--config=z-P=z	--plugin=r]   r   )r   zPlugin not found: %soptions)r   zcommand line args: %szplugin is: %s)listrw   argvlenr6   
startswithr   
parse_argsr[   r   r`   ra   r"   r   r1   r2   r3   r   console
printErrorexitextendrb   rU   rm   )cmd_line_argsstage_one_argsidxauto_appendoptparserr   r   plugin_namePluginClassr   s              r   parseCommandLiner      sE   +8D'd388AB<>PM NC
M"
"C !!#&KEE!!#&m#"nnU#s~~k'Bu%)D!!#&q M"
"  F^,DF{{kk	F%%i:jjH5(K$--$$[v8N$OK&&'='KLA F&##Iy9VZZ	9=CCEF&##K;VZZY?EEGH -0DDK	IIOO+T2	IIOOOV,r   c                     t                d} 	 t               \  } }}t        j                  j                  j
                  j                  | j                          | j                  du rt        nt        } || |      }t7        j<                  |       y# t        $ r d}Y #t        t        f$ r>}t        j                  j                  j                  t        |             d}Y d}~jd}~wt         $ r}t        j                  j                  j                  d| d       t        j"                  j%                  |       d}| j&                  r	 t)        j*                         5  t)        j,                  dt.               ddl}ddd       n# 1 sw Y   nxY wn# t2        $ r ddl}Y nw xY wt7        j8                         \  }}}	j;                  |	       Y d}~\d}~ww xY w)zEntry pointNFr   r*   zUncaught exception: 
ignore)r   r   r   r   r   	AnsiCodesinitr   debug_profiler   r}   KeyboardInterruptStopIterationrW   r   str	ExceptionrU   	exception	debug_pdbwarningscatch_warningssimplefilterPendingDeprecationWarningipdbImportErrorpdbrw   exc_infopost_mortemr   )
r   rI   r   mainFuncr   rZ   r   emtbs
             r   _mainr   
  so   MD *,a%%**t}}+<=--64K$'0 HHV/  7# &&s2w/  &&)=bT'DE		B>>,,. '))(4MN '	' ' '
   ||~HAq"OOB! sg   A/B G G.4C''G3AGF"F
	F
F	FGF'$G&F'',GG__main__)FPATHzFiles or directory paths)N)'rL   rw   r;   r   deprecationior   configparserr   r   rT   r   r   r0   eyed3.pluginseyed3.__about__eyed3.utils.logr   r"   rM   rd   rP   r_   rQ   USER_PLUGINS_DIR_DEPRECATEDr   r   
deprecatedr   __version__rJ   r[   r3   r}   r   r   r   r   __name__rH   r   r   <module>r      s   	 
     % 3      '##$FG77%%&EF GG../JK  gg001IJ .: g%(-(C(C"@@P QS(S(C:0 KQ"<X,!H9 x#L z	G r   