a
    ”$a•c  ã                   @   s~   d Z ddlZddlZddlZddlZddlmZmZ dZdd„ Z	dd„ Z
d	d
„ ZG dd„ deƒZej ¡ ZG dd„ deƒZdS )a\  
Node: filesystem structure

#. Each file/folder is represented by exactly one node.

#. Some potential class properties are stored on :py:class:`waflib.Build.BuildContext` : nodes to depend on, etc.
   Unused class members can increase the `.wafpickle` file size sensibly.

#. Node objects should never be created directly, use
   the methods :py:func:`Node.make_node` or :py:func:`Node.find_node` for the low-level operations

#. The methods :py:func:`Node.find_resource`, :py:func:`Node.find_dir` :py:func:`Node.find_or_declare` must be
   used when a build context is present

#. Each instance of :py:class:`waflib.Context.Context` has a unique :py:class:`Node` subclass required for serialization.
   (:py:class:`waflib.Node.Nod3`, see the :py:class:`waflib.Context.Context` initializer). A reference to the context
   owning a node is held as *self.ctx*
é    N)ÚUtilsÚErrorsa:  
**/*~
**/#*#
**/.#*
**/%*%
**/._*
**/*.swp
**/CVS
**/CVS/**
**/.cvsignore
**/SCCS
**/SCCS/**
**/vssver.scc
**/.svn
**/.svn/**
**/BitKeeper
**/.git
**/.git/**
**/.gitignore
**/.bzr
**/.bzrignore
**/.bzr/**
**/.hg
**/.hg/**
**/_MTN
**/_MTN/**
**/.arch-ids
**/{arch}
**/_darcs
**/_darcs/**
**/.intlcache
**/.DS_Storec           	      C   sü   |r
t jnd}g }t | ¡D ]Ú}| dd¡ dd¡}| d¡rF|d7 }g }| d¡D ]–}|dkrl| |¡ qT| dd¡ dd	¡ d
d¡ dd¡}d| }zt j||d}W n4 t	yÞ } zt
 d| |¡‚W Y d }~qTd }~0 0 | |¡ qT| |¡ q|S )Nr   ú\ú/z//ú**Ú.z[.]Ú*z.*ú?ú+z\+z^%s$)ÚflagszInvalid pattern: %s)ÚreÚIr   Úto_listÚreplaceÚendswithÚsplitÚappendÚcompileÚ	Exceptionr   ÚWafError)	ÚsÚ
ignorecaseZreflagsÚretÚxZaccuÚkÚexpÚe© r   úf/home/jack/SDK/ZBT-AX3000-OpenWrt-21.02/build_dir/hostpkg/samba-4.14.12/third_party/waf/waflib/Node.pyÚant_matcher@   s&    
$&r   c                 C   sˆ   g }|D ]z}|sq|d dkrb|  |¡ t|ƒdkrV|d  | ¡r`|  |dd … ¡ q‚|  g ¡ q|d  | ¡r|  |dd … ¡ q|S )Nr   r   é   é   )r   ÚlenÚmatch)ÚnameZnnr   Úlstr   r   r   Úant_sub_filterW   s    
r&   c                 C   s0   t | |d ƒ}t | |d ƒ}g |v r(g }||gS )Nr   r    )r&   )r$   ÚpatsZnaccZnrejr   r   r   Úant_sub_matcherg   s
    r(   c                   @   sŠ  e Zd ZdZeZdZdd„ Zdd„ Zdd„ Z	d	d
„ Z
dd„ Zdd„ Zd^dd„Zd_dd„Zd`dd„Zdadd„Zdd„ Zdd„ Zd d!„ Zdbd"d#„Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zej rìd8d7„ Zd9d:„ Z!d;d<g d=ddd=fd>d?„Z"d@dA„ Z#dBdC„ Z$dDdE„ Z%dFdG„ Z&dHdI„ Z'dJdK„ Z(dLdM„ Z)dNdO„ Z*dcdPdQ„Z+dRdS„ Z,dTdU„ Z-dVdW„ Z.dXdY„ Z/dZd[„ Z0d\d]„ Z1d;S )dÚNodezî
	This class is organized in two parts:

	* The basic methods meant for filesystem access (compute paths, create folders, etc)
	* The methods bound to a :py:class:`waflib.Build.BuildContext` (require ``bld.srcnode`` and ``bld.bldnode``)
	)r$   ÚparentÚchildrenÚcache_abspathÚcache_isdirc                 C   s:   || _ || _|r6||jv r,t d||f ¡‚| |j|< dS )zn
		.. note:: Use :py:func:`Node.make_node` or :py:func:`Node.find_node` instead of calling this constructor
		z-node %s exists in the parent files %r alreadyN)r$   r*   r+   r   r   )Úselfr$   r*   r   r   r   Ú__init__|   s    
zNode.__init__c                 C   s4   |d | _ |d | _|d dur0|  |d ¡| _dS )z3Deserializes node information, used for persistencer   r    r!   N)r$   r*   Ú
dict_classr+   )r.   Údatar   r   r   Ú__setstate__‡   s    

zNode.__setstate__c                 C   s   | j | jt| ddƒfS )z1Serializes node information, used for persistencer+   N)r$   r*   Úgetattr©r.   r   r   r   Ú__getstate__   s    zNode.__getstate__c                 C   s   |   ¡ S ©zO
		String representation (abspath), for debugging purposes

		:rtype: string
		©Úabspathr4   r   r   r   Ú__str__“   s    zNode.__str__c                 C   s   |   ¡ S r6   r7   r4   r   r   r   Ú__repr__›   s    zNode.__repr__c                 C   s   t  d¡‚dS )z`
		Provided to prevent nodes from being copied

		:raises: :py:class:`waflib.Errors.WafError`
		z#nodes are not supposed to be copiedN)r   r   r4   r   r   r   Ú__copy__£   s    zNode.__copy__Úrúlatin-1c                 C   s   t  |  ¡ ||¡S )aW  
		Reads and returns the contents of the file represented by this node, see :py:func:`waflib.Utils.readf`::

			def build(bld):
				bld.path.find_node('wscript').read()

		:param flags: Open mode
		:type  flags: string
		:param encoding: encoding value for Python3
		:type encoding: string
		:rtype: string or bytes
		:return: File contents
		)r   Úreadfr8   )r.   r   Úencodingr   r   r   Úread«   s    z	Node.readÚwc                 C   s   t  |  ¡ |||¡ dS )aV  
		Writes data to the file represented by this node, see :py:func:`waflib.Utils.writef`::

			def build(bld):
				bld.path.make_node('foo.txt').write('Hello, world!')

		:param data: data to write
		:type  data: string
		:param flags: Write mode
		:type  flags: string
		:param encoding: encoding value for Python3
		:type encoding: string
		N)r   Úwritefr8   )r.   r1   r   r?   r   r   r   Úwrite»   s    z
Node.writeTúutf-8c                    sn   ddl }d}ˆrXtjdk rXzt‰ W n ty8   t‰ Y n0 ‡ ‡fdd„‰‡fdd„}|}|j| j|d|d	S )
u  
		Reads and parses the contents of this node as JSON (Python â‰¥ 2.6)::

			def build(bld):
				bld.path.find_node('abc.json').read_json()

		Note that this by default automatically decodes unicode strings on Python2, unlike what the Python JSON module does.

		:type  convert: boolean
		:param convert: Prevents decoding of unicode strings on Python2
		:type  encoding: string
		:param encoding: The encoding of the file to read. This default to UTF8 as per the JSON standard
		:rtype: object
		:return: Parsed file contents
		r   Ni   c                    s6   t | tƒr‡fdd„| D ƒS t | ˆ ƒr.t| ƒS | S d S )Nc                    s   g | ]}ˆ |ƒ‘qS r   r   )Ú.0Úelement©Úconvertr   r   Ú
<listcomp>å   ó    z3Node.read_json.<locals>.convert.<locals>.<listcomp>)Ú
isinstanceÚlistÚstr)Úvalue©Z_typerH   r   r   rH   ã   s
    

zNode.read_json.<locals>.convertc                    s   t ‡ fdd„| D ƒƒS )Nc                 3   s&   | ]}t |d  ƒˆ |d ƒfV  qdS )r   r    N)rM   )rE   ÚpairrG   r   r   Ú	<genexpr>ì   rJ   z7Node.read_json.<locals>.object_pairs.<locals>.<genexpr>)Údict)ZpairsrG   r   r   Úobject_pairsë   s    z$Node.read_json.<locals>.object_pairs©r?   )Úobject_pairs_hook)ÚjsonÚsysÚ
hexversionÚunicodeÚ	NameErrorrM   Úloadsr@   )r.   rH   r?   rV   rU   rS   r   rO   r   Ú	read_jsonË   s    
zNode.read_jsonc           	      C   sR   ddl }d}d}|}tj}|s*d}d}d}|j||||d| }| j|dd	 dS )
uD  
		Writes a python object as JSON to disk (Python â‰¥ 2.6) as UTF-8 data (JSON standard)::

			def build(bld):
				bld.path.find_node('xyz.json').write_json(199)

		:type  data: object
		:param data: The data to write to disk
		:type  pretty: boolean
		:param pretty: Determines if the JSON will be nicely space separated
		r   Nr!   )ú,z: )r]   ú:Ú )ÚindentÚ
separatorsÚ	sort_keysrD   rT   )rV   ÚosÚlinesepÚdumpsrC   )	r.   r1   ZprettyrV   r`   ra   rb   ÚnewlineÚoutputr   r   r   Ú
write_jsonò   s    zNode.write_jsonc                 C   s   t j |  ¡ ¡S )zK
		Returns whether the Node is present on the filesystem

		:rtype: bool
		)rc   ÚpathÚexistsr8   r4   r   r   r   rj   
  s    zNode.existsc                 C   s   t j |  ¡ ¡S )zB
		Returns whether the Node represents a folder

		:rtype: bool
		)rc   ri   Úisdirr8   r4   r   r   r   rk     s    z
Node.isdirc                 C   s   t  |  ¡ |¡ dS )z[
		Changes the file/dir permissions::

			def build(bld):
				bld.path.chmod(493) # 0755
		N)rc   Úchmodr8   ©r.   Úvalr   r   r   rl     s    z
Node.chmodc                 C   s|   zhz2t j |  ¡ ¡r$t |  ¡ ¡ nt  |  ¡ ¡ W n$ tyX   t j |  ¡ ¡rT‚ Y n0 W |rx|  	¡  n|rv|  	¡  0 dS )zª
		Removes the file/folder from the filesystem (equivalent to `rm -rf`), and remove this object from the Node tree.
		Do not use this object after calling this method.
		N)
rc   ri   rk   r8   ÚshutilÚrmtreeÚremoveÚOSErrorrj   Úevict)r.   rs   r   r   r   Údelete#  s    

ÿzNode.deletec                 C   s   | j j| j= dS )z*
		Removes this node from the Node tree
		N)r*   r+   r$   r4   r   r   r   rs   5  s    z
Node.evictc                 C   s    t d| j d¡ƒ}| j|d… S )uZ   
		Returns the file rightmost extension, for example `a.b.c.d â†’ .d`

		:rtype: string
		r   r   N)Úmaxr$   Úrfind)r.   r   r   r   r   Úsuffix;  s    zNode.suffixc                 C   s    | }d}|r|j }|d7 }q|S )z”
		Returns the depth in the folder hierarchy from the filesystem root or from all the file drives

		:returns: filesystem depth
		:rtype: integer
		éÿÿÿÿr    )r*   )r.   Údrn   r   r   r   ÚheightD  s    
zNode.heightc                 C   s   t  |  ¡ ¡}| ¡  |S )zv
		Lists the folder contents

		:returns: list of file/folder names ordered alphabetically
		:rtype: list of string
		)r   Úlistdirr8   Úsort)r.   r%   r   r   r   r{   R  s    zNode.listdirc                 C   sœ   |   ¡ rdS z| j ¡  W n ty,   Y n0 | jr˜zt |  ¡ ¡ W n tyX   Y n0 |   ¡ spt 	d|  ¡‚z
| j
 W n ty–   |  ¡ | _
Y n0 dS )z¦
		Creates a folder represented by this node. Intermediate folders are created as needed.

		:raises: :py:class:`waflib.Errors.WafError` when the folder is missing
		Nz!Could not create the directory %r)rk   r*   Úmkdirrr   r$   rc   Úmakedirsr8   r   r   r+   ÚAttributeErrorr0   r4   r   r   r   r}   ]  s"    
z
Node.mkdirc              	   C   s
  t |tƒrdd„ t |¡D ƒ}|r`|d  d¡r`| js`| jj |d ¡}d|_	| 
|dd… ¡S | }|D ]†}|dkr€|jp||}qhz
|j}W n ty¦   |  ¡ |_Y n&0 z|| }W qhW n tyÊ   Y n0 |  ||¡}| ¡ sh| ¡   dS qh| ¡ s| ¡  dS |S )	u7  
		Finds a node on the file system (files or folders), and creates the corresponding Node objects if it exists

		:param lst: relative path
		:type lst: string or list of string
		:returns: The corresponding Node object or None if no entry was found on the filesystem
		:rtype: :py:class:Â´waflib.Node.NodeÂ´
		c                 S   s   g | ]}|r|d kr|‘qS ©r   r   ©rE   r   r   r   r   rI   „  rJ   z"Node.find_node.<locals>.<listcomp>r   z\\Tr    Nú..)rK   rM   r   Ú
split_pathÚ
startswithr*   ÚctxÚrootÚ	make_noder-   Ú	find_noder+   r   r0   ÚKeyErrorÚ	__class__rj   rs   )r.   r%   ÚnodeÚcurr   Zchr   r   r   rˆ   y  s8    




zNode.find_nodec              	   C   sŽ   t |tƒrdd„ t |¡D ƒ}| }|D ]b}|dkr>|jp:|}q&z|j| }W q& tyh   |  ¡ |_Y n tyx   Y n0 q&|  	||¡}q&|S )uÖ   
		Returns or creates a Node object corresponding to the input path without considering the filesystem.

		:param lst: relative path
		:type lst: string or list of string
		:rtype: :py:class:Â´waflib.Node.NodeÂ´
		c                 S   s   g | ]}|r|d kr|‘qS r€   r   r   r   r   r   rI   ±  rJ   z"Node.make_node.<locals>.<listcomp>r‚   )
rK   rM   r   rƒ   r*   r+   r   r0   r‰   rŠ   ©r.   r%   rŒ   r   r   r   r   r‡   ¨  s     

zNode.make_nodec              
   C   sn   t |tƒrdd„ t |¡D ƒ}| }|D ]B}|dkr>|jp:|}q&z|j| }W q& ttfyf   Y  dS 0 q&|S )u  
		Returns a Node previously defined in the data structure. The filesystem is not considered.

		:param lst: relative path
		:type lst: string or list of string
		:rtype: :py:class:Â´waflib.Node.NodeÂ´ or None if there is no entry in the Node datastructure
		c                 S   s   g | ]}|r|d kr|‘qS r€   r   r   r   r   r   rI   Í  rJ   z$Node.search_node.<locals>.<listcomp>r‚   N)rK   rM   r   rƒ   r*   r+   r   r‰   r   r   r   r   Úsearch_nodeÄ  s    
zNode.search_nodec                 C   sÈ   | }|}|  ¡ }|  ¡ }g }d}||krD| |j¡ |j}|d8 }q ||krd|d7 }|j}|d8 }qD||urŽ| |j¡ |d7 }|j}|j}qd|jr¼| dg| ¡ | ¡  tj |¡pºdS |  	¡ S dS )aj  
		Path of this node seen from the other::

			def build(bld):
				n1 = bld.path.find_node('foo/bar/xyz.txt')
				n2 = bld.path.find_node('foo/stuff/')
				n1.path_from(n2) # '../bar/xyz.txt'

		:param node: path to use as a reference
		:type node: :py:class:`waflib.Node.Node`
		:returns: a relative path or an absolute one if that is better
		:rtype: string
		r   r    r‚   r   N)
rz   r   r$   r*   ÚextendÚreverserc   ÚsepÚjoinr8   )r.   r‹   Úc1Úc2Zc1hZc2hr%   Úupr   r   r   Ú	path_fromÚ  s0    

zNode.path_fromc                 C   s`   z| j W S  ty   Y n0 | js*tj}n,| jjs@tj| j }n| j ¡ tj | j }|| _ |S )zk
		Returns the absolute path. A cache is kept in the context as ``cache_node_abspath``

		:rtype: string
		)r,   r   r*   rc   r‘   r$   r8   rm   r   r   r   r8   	  s    zNode.abspathc                 C   sf   z| j W S  ty   Y n0 | js(d}n4| jjs>| jtj }n| j ¡  tj¡tj | j }|| _ |S )Nr_   )r,   r   r*   r$   rc   r‘   r8   Úrstriprm   r   r   r   r8     s    c                 C   s4   | }|   ¡ |  ¡  }|dkr,|d8 }|j}q||u S )a  
		Returns whether the object belongs to a subtree of the input node::

			def build(bld):
				node = bld.path.find_node('wscript')
				node.is_child_of(bld.path) # True

		:param node: path to use as a reference
		:type node: :py:class:`waflib.Node.Node`
		:rtype: bool
		r   r    )rz   r*   )r.   r‹   ÚpZdiffr   r   r   Úis_child_of-  s    zNode.is_child_ofNé   Fc              
   c   sô   |   ¡ }zt| j ¡ ƒ}	W n ty6   |  ¡ | _Y n&0 |r\|	t|ƒ D ]}
| j|
  ¡  qH|D ]Ž}|||ƒ}|r`|d r`g |d v }|  |g¡}| ¡ }|r¸|r®|r¸|V  n
|r¸|V  |r`d|_	|r`|j
||d |||||dD ]
}|V  qâq`dS )a  
		Recursive method used by :py:meth:`waflib.Node.ant_glob`.

		:param accept: function used for accepting/rejecting a node, returns the patterns that can be still accepted in recursion
		:type accept: function
		:param maxdepth: maximum depth in the filesystem (25)
		:type maxdepth: int
		:param pats: list of patterns to accept and list of patterns to exclude
		:type pats: tuple
		:param dir: return folders too (False by default)
		:type dir: bool
		:param src: return files (True by default)
		:type src: bool
		:param remove: remove files/folders that do not exist (True by default)
		:type remove: bool
		:param quiet: disable build directory traversal warnings (verbose mode)
		:type quiet: bool
		:returns: A generator object to iterate from
		:rtype: iterator
		r   Tr    )ÚacceptÚmaxdepthr'   ÚdirÚsrcrq   ÚquietN)r{   Úsetr+   Úkeysr   r0   rs   r‡   rk   r-   Úant_iter)r.   r›   rœ   r'   r   rž   rq   rŸ   Zdircontr%   r   r$   ZnpatsZacceptedr‹   rk   r   r   r   r   r¢   @  s2    
 zNode.ant_iterc              
      sä   |  dd¡}|  d¡}|  dt¡}|r.|d p8|  dd¡}|  dd¡}|  d	d
¡}|  dd¡}	|  dd¡}
t||	ƒt||	ƒf}|  d¡r¤t ˆ jt||||||
f¡S ˆ  t||||||
¡}|  d¡rÜd ‡ fdd„|D ƒ¡S t|ƒS )aö  
		Finds files across folders and returns Node objects:

		* ``**/*`` find all files recursively
		* ``**/*.class`` find all files ending by .class
		* ``..`` find files having two dot characters

		For example::

			def configure(cfg):
				# find all .cpp files
				cfg.path.ant_glob('**/*.cpp')
				# find particular files from the root filesystem (can be slow)
				cfg.root.ant_glob('etc/*.txt')
				# simple exclusion rule example
				cfg.path.ant_glob('*.c*', excl=['*.c'], src=True, dir=False)

		For more information about the patterns, consult http://ant.apache.org/manual/dirtasks.html
		Please remember that the '..' sequence does not represent the parent directory::

			def configure(cfg):
				cfg.path.ant_glob('../*.h') # incorrect
				cfg.path.parent.ant_glob('*.h') # correct

		The Node structure is itself a filesystem cache, so certain precautions must
		be taken while matching files in the build or installation phases.
		Nodes objects that do have a corresponding file or folder are garbage-collected by default.
		This garbage collection is usually required to prevent returning files that do not
		exist anymore. Yet, this may also remove Node objects of files that are yet-to-be built.

		This typically happens when trying to match files in the build directory,
		but there are also cases when files are created in the source directory.
		Run ``waf -v`` to display any warnings, and try consider passing ``remove=False``
		when matching files in the build directory.

		Since ant_glob can traverse both source and build folders, it is a best practice
		to call this method only from the most specific build node::

			def build(bld):
				# traverses the build directory, may need ``remove=False``:
				bld.path.ant_glob('project/dir/**/*.h')
				# better, no accidental build directory traversal:
				bld.path.find_node('project/dir').ant_glob('**/*.h') # best

		In addition, files and folders are listed immediately. When matching files in the
		build folders, consider passing ``generator=True`` so that the generator object
		returned can defer computation to a later stage. For example::

			def build(bld):
				bld(rule='tar xvf ${SRC}', source='arch.tar')
				bld.add_group()
				gen = bld.bldnode.ant_glob("*.h", generator=True, remove=True)
				# files will be listed only after the arch.tar is unpacked
				bld(rule='ls ${SRC}', source=gen, name='XYZ')


		:param incl: ant patterns or list of patterns to include
		:type incl: string or list of strings
		:param excl: ant patterns or list of patterns to exclude
		:type excl: string or list of strings
		:param dir: return folders too (False by default)
		:type dir: bool
		:param src: return files (True by default)
		:type src: bool
		:param maxdepth: maximum depth of recursion
		:type maxdepth: int
		:param ignorecase: ignore case while matching (False by default)
		:type ignorecase: bool
		:param generator: Whether to evaluate the Nodes lazily
		:type generator: bool
		:param remove: remove files/folders that do not exist (True by default)
		:type remove: bool
		:param quiet: disable build directory traversal warnings (verbose mode)
		:type quiet: bool
		:returns: The corresponding Node objects as a list or as a generator object (generator=True)
		:rtype: by default, list of :py:class:`waflib.Node.Node` instances
		rž   Tr   Úexclr   Úinclr   rq   rœ   rš   r   FrŸ   Ú	generatorZflatú c                 3   s   | ]}|  ˆ ¡V  qd S )N)r–   r   r4   r   r   rQ   Ô  rJ   z Node.ant_glob.<locals>.<genexpr>)	ÚgetÚexclude_regsr   r   Úlazy_generatorr¢   r(   r’   rL   )r.   r   Úkwrž   r   r£   r¤   rq   rœ   r   rŸ   r'   Úitr   r4   r   Úant_globu  s    N


zNode.ant_globc                 C   s>   | }| j j}| j j}|jr:||u r&dS ||u r2dS |j}qdS )ur   
		Returns True if the node is below the source directory. Note that ``!is_src() â‰  is_bld()``

		:rtype: bool
		FT)r…   ÚsrcnodeÚbldnoder*   )r.   rŒ   r   Úyr   r   r   Úis_srcÚ  s    zNode.is_srcc                 C   s*   | }| j j}|jr&||u rdS |j}qdS )uq   
		Returns True if the node is below the build directory. Note that ``!is_bld() â‰  is_src()``

		:rtype: bool
		TF)r…   r®   r*   )r.   rŒ   r¯   r   r   r   Úis_bldë  s    zNode.is_bldc                 C   s\   | }| j j}| j j}g }|jrX||u r8| ¡  | |¡S ||u rD| S | |j¡ |j}q| S )a!  
		Returns the corresponding Node object in the source directory (or self if already
		under the source directory). Use this method only if the purpose is to create
		a Node object (this is common with folders but not with files, see ticket 1937)

		:rtype: :py:class:`waflib.Node.Node`
		)r…   r­   r®   r*   r   r‡   r   r$   ©r.   rŒ   r   r¯   r%   r   r   r   Úget_srcù  s    
zNode.get_srcc                 C   s°   | }| j j}| j j}g }|jr\||u r*| S ||u rH| ¡  | j j |¡S | |j¡ |j}q| ¡  |rœtj	rœt
|d ƒdkrœ|d  d¡rœ|d d |d< | j j dg| ¡S )a  
		Return the corresponding Node object in the build directory (or self if already
		under the build directory). Use this method only if the purpose is to create
		a Node object (this is common with folders but not with files, see ticket 1937)

		:rtype: :py:class:`waflib.Node.Node`
		r   r!   r^   Z__root__)r…   r­   r®   r*   r   r‡   r   r$   r   Úis_win32r"   r   r²   r   r   r   Úget_bld  s     (zNode.get_bldc                 C   sR   t |tƒrdd„ t |¡D ƒ}|  ¡  |¡}|s>|  ¡  |¡}|rN| ¡ rNdS |S )a·  
		Use this method in the build phase to find source files corresponding to the relative path given.

		First it looks up the Node data structure to find any declared Node object in the build directory.
		If None is found, it then considers the filesystem in the source directory.

		:param lst: relative path
		:type lst: string or list of string
		:returns: the corresponding Node object or None
		:rtype: :py:class:`waflib.Node.Node`
		c                 S   s   g | ]}|r|d kr|‘qS r€   r   r   r   r   r   rI   6  rJ   z&Node.find_resource.<locals>.<listcomp>N)	rK   rM   r   rƒ   rµ   rŽ   r³   rˆ   rk   ©r.   r%   r‹   r   r   r   Úfind_resource)  s    
zNode.find_resourcec                 C   sB   t |tƒr&tj |¡r&| jj |¡}n|  ¡  |¡}|j	 
¡  |S )a  
		Use this method in the build phase to declare output files which
		are meant to be written in the build directory.

		This method creates the Node object and its parent folder
		as needed.

		:param lst: relative path
		:type lst: string or list of string
		)rK   rM   rc   ri   Úisabsr…   r†   r‡   rµ   r*   r}   r¶   r   r   r   Úfind_or_declare?  s
    
zNode.find_or_declarec                 C   s<   t |tƒrdd„ t |¡D ƒ}|  |¡}|r8| ¡ s8dS |S )a  
		Searches for a folder on the filesystem (see :py:meth:`waflib.Node.Node.find_node`)

		:param lst: relative path
		:type lst: string or list of string
		:returns: The corresponding Node object or None if there is no such folder
		:rtype: :py:class:`waflib.Node.Node`
		c                 S   s   g | ]}|r|d kr|‘qS r€   r   r   r   r   r   rI   [  rJ   z!Node.find_dir.<locals>.<listcomp>N)rK   rM   r   rƒ   rˆ   rk   r¶   r   r   r   Úfind_dirQ  s    	

zNode.find_dirc                 C   s`   | j }|du r<| d¡}|dkr2|d|… | }qR|| }n|dt|ƒ … | }| j |g¡S )zà
		Declares a build node with a distinct extension; this is uses :py:meth:`waflib.Node.Node.find_or_declare`

		:return: A build node of the same path, but with a different extension
		:rtype: :py:class:`waflib.Node.Node`
		Nr   r   )r$   rv   r"   r*   r¹   )r.   ÚextÚext_inr$   r   r   r   r   Ú
change_extc  s    

zNode.change_extc                 C   s   |   | jj¡S )z_
		Returns the relative path seen from the build directory ``src/foo.cpp``

		:rtype: string
		)r–   r…   r®   r4   r   r   r   Úbldpathv  s    zNode.bldpathc                 C   s   |   | jj¡S )zc
		Returns the relative path seen from the source directory ``../src/foo.cpp``

		:rtype: string
		)r–   r…   r­   r4   r   r   r   Úsrcpath~  s    zNode.srcpathc                 C   s2   | }| j j}|jr*||u r"|  ¡ S |j}q|  ¡ S )z™
		If a file in the build directory, returns :py:meth:`waflib.Node.Node.bldpath`,
		else returns :py:meth:`waflib.Node.Node.srcpath`

		:rtype: string
		)r…   r®   r*   r¾   r¿   )r.   rŒ   r   r   r   r   Úrelpath†  s    zNode.relpathc                 C   s
   | j  ¡ S )z;
		Equivalent to self.parent.bldpath()

		:rtype: string
		)r*   r¾   r4   r   r   r   Úbld_dir•  s    zNode.bld_dirc                 C   s   t  |  ¡ ¡S )zt
		See :py:func:`waflib.Utils.h_file`

		:return: a hash representing the file contents
		:rtype: string or bytes
		)r   Úh_filer8   r4   r   r   r   rÂ     s    zNode.h_filec                 C   s¼   z| j j}W n ty*   i  }| j _Y n0 z||  }W n~ ty¶   |  ¡ }z|  ¡  }|| < W nN ty°   |  ¡ rªt 	|¡}t
 ||j|jg¡ }|| < | Y  Y S ‚ Y n0 Y n0 |S )zé
		Returns a signature (see :py:meth:`waflib.Node.Node.h_file`) for the purpose
		of build dependency calculation. This method uses a per-context cache.

		:return: a hash representing the object contents
		:rtype: string or bytes
		)r…   Ú	cache_sigr   r‰   r8   rÂ   ÚEnvironmentErrorrk   rc   Ústatr   Úh_listÚst_inoÚst_mode)r.   Úcacher   r˜   Ústr   r   r   Úget_bld_sig¦  s"    	
zNode.get_bld_sig)r<   r=   )rA   r=   )TrD   )T)T)N)2Ú__name__Ú
__module__Ú__qualname__Ú__doc__rR   r0   Ú	__slots__r/   r2   r5   r9   r:   r;   r@   rC   r\   rh   rj   rk   rl   rt   rs   rw   rz   r{   r}   rˆ   r‡   rŽ   r–   r8   r   r´   r™   r¢   r¬   r°   r±   r³   rµ   r·   r¹   rº   r½   r¾   r¿   rÀ   rÁ   rÂ   rË   r   r   r   r   r)   n   s\   


'
	
	//5e
	r)   c                   @   s   e Zd ZdZdS )ÚNod3z5Mandatory subclass for thread-safe node serializationN)rÌ   rÍ   rÎ   rÏ   r   r   r   r   rÑ   Å  s   rÑ   )rÏ   rc   r   rW   ro   Úwaflibr   r   r¨   r   r&   r(   Úobjectr)   Ú	threadingÚLockZpickle_lockrÑ   r   r   r   r   Ú<module>   s    %      Z
