
    >Tfl                     J    d dl Z d dlmZ d dlmZ d Zd Zd Zd Zd Z	d	 Z
dS )
    N)ContentType)transactionc                     |  d| S N: )ct_id	object_ids     //var/www/html/netbox-4.1.3/netbox/dcim/utils.pycompile_path_noder      s    !!i!!!    c                 n    |                      d          \  }}t          |          t          |          fS r   )splitint)reprr	   r
   s      r   decompile_path_noder      s-    zz#E9u::s9~~%%r   c                 t    t           j                            |           }t          |j        | j                  S )z
    Return a representation of an object suitable for inclusion in a CablePath path. Node representation is in the
    form <ContentType ID>:<Object ID>.
    )r   objectsget_for_modelr   pk)objcts     r   object_to_path_noder      s.    
 
		*	*3	/	/BRUCF+++r   c                     t          |           \  }}t          j                            |          }|                                j                            |                                          S )z
    Given the string representation of a path node, return the corresponding instance. If the object no longer
    exists, return None.
    )r   )r   r   r   
get_for_idmodel_classfilterfirst)r   r	   r
   r   s       r   path_node_to_objectr      s\    
 +400E9			'	'	.	.B>>#**i*88>>@@@r   c                 l    ddl m} |                    |           }|r|                                 dS dS )z
    Create CablePaths for all paths originating from the specified set of nodes.

    :param terminations: Iterable of CableTermination objects
    r   	CablePathN)dcim.modelsr"   from_originsave)terminationsr"   cps      r   create_cablepathr(   #   sL     &%%%%%			|	,	,B	 
					 r   c                    ddl m} | D ]v}|j                            |          }t	          j                    5  |D ]*}|                                 t          |j                   +	 ddd           n# 1 swxY w Y   wdS )zD
    Rebuild all CablePaths which traverse the specified nodes.
    r   r!   )_nodes__containsN)	r#   r"   r   r   r   atomicdeleter(   origins)r&   r"   r   cable_pathsr'   s        r   rebuild_pathsr/   0   s     &%%%%% - -'...DD!! 	- 	-! - -		 ,,,,-	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-- -s   .A44A8	;A8	)	itertools"django.contrib.contenttypes.modelsr   	django.dbr   r   r   r   r   r(   r/   r   r   r   <module>r3      s        : : : : : : ! ! ! ! ! !" " "& & &
, , ,A A A
 
 
- - - - -r   