
ŝY	                 @   s   d  d l  Z d  d l m Z d  d l m Z d  d l Z d  d l Z d  d l Z e j   Z	 e	 j
 d d d d d e	 j
 d	 d d d d
 e	 j
 d d d d d e	 j
 d d d d d   Z d S)    N)MesonException)mlogz--sourcedirdefault.helpzPath to source directory.z--targetzName of target to edit.z
--filenamez/Name of source file to add or remove to target.commandsnargs+c             C   s  t  j |   } | j d  k s- | j d  k r= t j d  n  t d  t j j	 | j
 d  } yt | j d d k r | j | j | j  nD | j d d k r | j | j | j  n t j d | j d  Wn t k
 r} z t | t  ryt | d  rSt | d	  rSt | d
  rSt j t j d | j | j | j f   n t j t j d   t j |  n
 t j   d SWYd  d  } ~ Xn Xd S)Nz&Must specify both target and filename.z0This tool is highly experimental, use with care. r   addremovezUnknown command: filelinenocolnoz;
Meson encountered an error in file %s, line %d, column %d:z
Meson encountered an error:   )parser
parse_argstargetfilenamesysexitprint
mesonbuildZastinterpreterZAstInterpreterZ	sourcedirr   Z
add_sourceZremove_source	Exception
isinstancer   hasattrr   logredr   r   r   	traceback	print_exc)argsoptionsrewritere r$   O/mnt/raid6/a/bak/reczko/tools/protein/utils/meson-0.42.1/mesonbuild/rewriter.pyrun*   s(    
-/
r&   )Zmesonbuild.astinterpreterr   Zmesonbuild.mesonlibr   r   r   r   argparseArgumentParserr   add_argumentr&   r$   r$   r$   r%   <module>   s   