Ñò
 „Pc           @   so   d  Z  d d k Z d d k Z d d k Z d d k l Z l Z e i d e i ƒ Z	 d e
 f d „  ƒ  YZ d S(   sS   

ConfigSet: a special dict

The values put in :py:class:`ConfigSet` must be lists
iÿÿÿÿN(   t   Logst   Utilss   ^(#)*?([^#=]*?)\ =\ (.*?)$t	   ConfigSetc           B   sæ   e  Z d  Z d Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sš  
	A dict that honor serialization and parent relationships. The serialization format
	is human-readable (python-like) and performed by using eval() and repr().
	For high performance prefer pickle. Do not store functions as they are not serializable.

	The values can be accessed by attributes or by keys::

		from waflib.ConfigSet import ConfigSet
		env = ConfigSet()
		env.FOO = 'test'
		env['FOO'] = 'test'
	t   tablet   parentc         C   s%   h  |  _  | o |  i | ƒ n d  S(   N(   R   t   load(   t   selft   filename(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   __init__   s    	c         C   sD   | |  i  j o t Sy |  i i | ƒ SWn t j
 o t SXd S(   sH   
		Enable the *in* syntax::

			if 'foo' in env:
				print env['foo']
		N(   R   t   TrueR   t   __contains__t   AttributeErrort   False(   R   t   key(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR
   (   s       c         C   s`   t  ƒ  } |  } x4 | o, | i | i i ƒ  ƒ t | d d ƒ } q Wt | ƒ } | i ƒ  | S(   s    Dict interface (unknown purpose)R   N(   t   sett   updateR   t   keyst   getattrt   Nonet   listt   sort(   R   R   t   cur(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR   3   s    	 
c         C   sA   d i  g  } |  i ƒ  D]  } | d | |  i | ƒ f q ~ ƒ S(   s=   Text representation of the ConfigSet (for debugging purposes)s   
s   %r %r(   t   joinR   t   __getitem__(   R   t   _[1]t   x(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   __str__>   s    c         C   sU   y: x3 |  i  i | d ƒ } | d j	 o | S|  i }  q Wn t j
 o g  SXd S(   sx   
		Dictionary interface: get value from key::

			def configure(conf):
				conf.env['foo'] = {}
				print(env['foo'])
		N(   R   t   getR   R   R   (   R   R   R   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR   B   s    c         C   s   | |  i  | <d S(   s.   
		Dictionary interface: get value from key
		N(   R   (   R   R   t   value(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   __setitem__S   s    c         C   s   g  |  | <d S(   s.   
		Dictionary interface: get value from key
		N(    (   R   R   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   __delitem__Y   s    c         C   s-   | |  i  j o t i |  | ƒ S|  | Sd S(   s—   
		Attribute access provided for convenience. The following forms are equivalent::

			def configure(conf):
				conf.env.value
				conf.env['value']
		N(   t	   __slots__t   objectt   __getattr__(   R   t   name(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR!   _   s    c         C   s5   | |  i  j o t i |  | | ƒ n | |  | <d S(   sš   
		Attribute access provided for convenience. The following forms are equivalent::

			def configure(conf):
				conf.env.value = x
				env['value'] = x
		N(   R   R    t   __setattr__(   R   R"   R   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR#   l   s    c         C   s/   | |  i  j o t i |  | ƒ n |  | =d S(   s•   
		Attribute access provided for convenience. The following forms are equivalent::

			def configure(conf):
				del env.value
				del env['value']
		N(   R   R    t   __delattr__(   R   R"   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR$   y   s    c         C   s   t  ƒ  } |  | _ | S(   s½  
		Returns a new ConfigSet deriving from self. The copy returned
		will be a shallow copy::

			from waflib.ConfigSet import ConfigSet
			env = ConfigSet()
			env.append_value('CFLAGS', ['-O2'])
			child = env.derive()
			child.CFLAGS.append('test') # warning! this will modify 'env'
			child.CFLAGS = ['-O3'] # new list, ok
			child.append_value('CFLAGS', ['-O3']) # ok

		Use :py:func:`ConfigSet.detach` to detach the child from the parent.
		(   R   R   (   R   t   newenv(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   derive†   s    		c         C   st   |  i  ƒ  } y t |  d ƒ Wn t j
 o n? X| i ƒ  } x% | D] } t i | | ƒ | | <qF W| |  _ d S(   sÇ   
		Detach self from its parent (if existing)

		Modifying the parent :py:class:`ConfigSet` will not change the current object
		Modifying this :py:class:`ConfigSet` will not modify the parent one.
		R   N(   t   get_merged_dictt   delattrR   R   t   copyt   deepcopyR   (   R   t   tblR   R   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   detach™   s     c         C   s,   |  | } t  | t ƒ o | Sd i | ƒ S(   sŽ   
		Return a value as a string. If the input is a list, the value returned is space-separated.

		:param key: key to use
		:type key: string
		t    (   t
   isinstancet   strR   (   R   R   t   s(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   get_flat«   s    
 c         C   s¦   y |  i  | } Wnd t j
 oX y |  i | } Wn t j
 o g  } n Xt | t ƒ o | } q• | g } n Xt | t ƒ p | g } n | |  i  | <| S(   s    
		Return a list value for further modification.

		The list may be modified inplace and there is no need to do this afterwards::

			self.table[var] = value
		(   R   t   KeyErrorR   R   R.   R   (   R   R   R   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt    _get_list_value_for_modification¶   s      c         C   s=   |  i  | ƒ } t | t ƒ o | g } n | i | ƒ d S(   sš   
		Appends a value to the specified config key::

			def build(bld):
				bld.env.append_value('CFLAGS', ['-O2'])

		The value must be a list or a tuple
		N(   R3   R.   R/   t   extend(   R   t   vart   valt   current_value(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   append_valueÍ   s    	c         C   s;   t  | t ƒ o | g } n | |  i | ƒ |  i | <d S(   sœ   
		Prepends a value to the specified item::

			def configure(conf):
				conf.env.prepend_value('CFLAGS', ['-O2'])

		The value must be a list or a tuple
		N(   R.   R/   R3   R   (   R   R5   R6   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   prepend_valueÛ   s    	c         C   s_   t  | t ƒ o | g } n |  i | ƒ } x, | D]$ } | | j o | i | ƒ q3 q3 Wd S(   s»   
		Append a value to the specified item only if it's not already present::

			def build(bld):
				bld.env.append_unique('CFLAGS', ['-O2', '-g'])

		The value must be a list or a tuple
		N(   R.   R/   R3   t   append(   R   R5   R6   R7   R   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   append_uniqueè   s    	 c         C   sq   g  } |  } x: | i  d | i ƒ y | i } Wq t j
 o Pq Xq h  } x | D] } | i | ƒ qV W| S(   sl   
		Compute the merged dictionary from the fusion of self and all its parent

		:rtype: a ConfigSet object
		i    (   t   insertR   R   R   R   (   R   t
   table_listt   envt   merged_tableR   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR'   ù   s      	 c         C   sÒ   y! t  i t  i i | ƒ d ƒ Wn t j
 o n Xd } zx t | d ƒ } |  i ƒ  } t | i	 ƒ  ƒ } | i
 ƒ  x: | D]2 } | d j o | i d | | | f ƒ q~ q~ WWd | o | i ƒ  n Xd S(   s¦   
		Write the :py:class:`ConfigSet` data into a file. See :py:meth:`ConfigSet.load` for reading such files.

		:param filename: file to use
		:type filename: string
		i    t   wt
   undo_stacks   %s = %r
N(   t   ost   makedirst   patht   splitt   OSErrorR   t   openR'   R   R   R   t   writet   close(   R   R   t   fR?   R   t   k(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   store
  s     !
 'c         C   s{   |  i  } t i | d d ƒ} x< t i | ƒ D]+ } | i } t | d ƒ ƒ | | d ƒ <q. Wt i d t	 |  i  ƒ ƒ d S(   s©   
		Retrieve the :py:class:`ConfigSet` data from a file. See :py:meth:`ConfigSet.store` for writing such files

		:param filename: file to use
		:type filename: string
		t   mt   rUi   i   s   env: %sN(
   R   R   t   readft   re_impt   finditert   groupt   evalR    t   debugR/   (   R   R   R+   t   codeRM   t   g(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR   #  s    	 	 c         C   s+   x$ | i  ƒ  D] \ } } | |  | <q Wd S(   s‚   
		Dictionary interface: replace values from another dict

		:param d: object to use the value from
		:type d: dict-like object
		N(   t   items(   R   t   dRK   t   v(    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR   1  s     c         C   s,   |  i  |  i g |  _  |  i i ƒ  |  _ d S(   s8  
		Store the object state, to provide a kind of transaction support::

			env = ConfigSet()
			env.stash()
			try:
				env.append_value('CFLAGS', '-O3')
				call_some_method(env)
			finally:
				env.revert()

		The history is kept in a stack, and is lost during the serialization by :py:meth:`ConfigSet.store`
		N(   RA   R   R)   (   R   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   stash;  s    c         C   s   |  i  i d ƒ |  _ d S(   sL   
		Reverts the object to a previous state. See :py:meth:`ConfigSet.stash`
		iÿÿÿÿN(   RA   t   popR   (   R   (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   revertL  s    (   s   tables   parentN(   t   __name__t
   __module__t   __doc__R   R   R   R
   R   R   R   R   R   R!   R#   R$   R&   R,   R1   R3   R8   R9   R;   R'   RL   R   R   RZ   R\   (    (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyR      s2   
																				
	(   R_   R)   t   reRB   t   waflibR    R   t   compilet   MRP   R    R   (    (    (    s=   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/ConfigSet.pyt   <module>
   s   $