
    $g                    x    d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	  G d d          Z
 G d d	e          ZdS )
z-Module responsible for the objects inventory.    )annotationsN)dedent)BinaryIO
Collectionc                  `    e Zd ZdZ	 	 dddZddZ ej        d          Ze	dd            Z
dS )InventoryItemzInventory item.   Nnamestrdomainroleuripriorityintdispname
str | Nonec                ^    || _         || _        || _        || _        || _        |p|| _        dS )av  Initialize the object.

        Arguments:
            name: The item name.
            domain: The item domain, like 'python' or 'crystal'.
            role: The item role, like 'class' or 'method'.
            uri: The item URI.
            priority: The item priority. Only used internally by mkdocstrings and Sphinx.
            dispname: The item display name.
        Nr
   r   r   r   r   r   selfr
   r   r   r   r   r   s          V/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/mkdocstrings/inventory.py__init__zInventoryItem.__init__   s7    & 	!	%%-    returnc                    | j         }|| j        k    rd}| j        }|                    | j                  r |dt	          | j                            dz   }| j         d| j         d| j         d| j         d| d| S )zFormat this item as a Sphinx inventory line.

        Returns:
            A line formatted for an `objects.inv` file.
        -N$ :)r   r
   r   endswithlenr   r   r   )r   r   r   s      r   format_sphinxzInventoryItem.format_sphinx+   s     =ty  Hh<<	"" 	/'TY'(3.C)XXdkXXDIXXXXXXhXXXr   z.^(.+?)\s+(\S+):(\S+)\s+(-?\d+)\s+(\S+)\s*(.*)$linec           	        | j                             |          }|st          |          |                                \  }}}}}}|                    d          r|dd         |z   }|dk    r|} | ||||t          |          |          S )zSParse a line from a Sphinx v2 inventory file and return an `InventoryItem` from it.r   Nr   )sphinx_item_regexsearch
ValueErrorgroupsr    r   )	clsr#   matchr
   r   r   r   r   r   s	            r   parse_sphinxzInventoryItem.parse_sphinx;   s     %,,T22 	#T"""6;llnn3fdHc8<< 	"crc(T/Cs??Hs4sCMM8DDDr   r	   N)r
   r   r   r   r   r   r   r   r   r   r   r   )r   r   )r#   r   r   r   )__name__
__module____qualname____doc__r   r"   recompiler&   classmethodr,    r   r   r   r      s         #. . . . .4Y Y Y Y #
#TUU
E 
E 
E [
E 
E 
Er   r   c                  Z     e Zd ZdZdd  fd	Z	 	 d!d"dZd#dZeddd$d            Z xZ	S )%	Inventoryz,Inventory of collected and rendered objects.Nproject0.0.0itemslist[InventoryItem] | Noner   versionc                    t                                                       |pg }|D ]}|| |j        <   || _        || _        dS )zInitialize the object.

        Arguments:
            items: A list of items.
            project: The project name.
            version: The project version.
        N)superr   r
   r8   r<   )r   r:   r8   r<   item	__class__s        r   r   zInventory.__init__L   sR     	 	# 	#D"DOOr   r	   r
   r   r   r   r   r   r   r   r   Nonec                6    t          ||||||          | |<   dS )a|  Create and register an item.

        Arguments:
            name: The item name.
            domain: The item domain, like 'python' or 'crystal'.
            role: The item role, like 'class' or 'method'.
            uri: The item URI.
            priority: The item priority. Only used internally by mkdocstrings and Sphinx.
            dispname: The item display name.
        r   N)r   r   s          r   registerzInventory.register[   s2    & #
 
 
T


r   bytesc                D   t          d| j         d| j         d                                                              d          }d t          |                                 d           D             }|t          j        d	                    |          dz   d	          z   S )
ztFormat this inventory as a Sphinx `objects.inv` file.

        Returns:
            The inventory as bytes.
        zI
                # Sphinx inventory version 2
                # Project: z
                # Version: zX
                # The remainder of this file is compressed using zlib.
                utf8c                \    g | ])}|                                                     d           *S rF   )r"   encode).0r?   s     r   
<listcomp>z+Inventory.format_sphinx.<locals>.<listcomp>   sB     
 
 
   ''//
 
 
r   c                    | j         | j        fS )N)r   r
   )r?   s    r   <lambda>z)Inventory.format_sphinx.<locals>.<lambda>   s    TY?W r   )key   
	   )
r   r8   r<   lstriprI   sortedvalueszlibcompressjoin)r   headerliness      r   r"   zInventory.format_sphinxw   s      L  !L    VXXVF^^ 	
 
t{{}}2W2WXXX
 
 
 ejj&7&7%&?CCCCr   r5   )domain_filterin_filer   rY   Collection[str]c                  t          d          D ]}|                                 t          j        |                                                                          }d |D             }rfd|D             } | |          S )aM  Parse a Sphinx v2 inventory file and return an `Inventory` from it.

        Arguments:
            in_file: The binary file-like object to read from.
            domain_filter: A collection of domain values to allow (and filter out all other ones).

        Returns:
            An inventory containing the collected items.
           c                h    g | ]/}t                               |                    d                     0S rH   )r   r,   decode)rJ   r#   s     r   rK   z*Inventory.parse_sphinx.<locals>.<listcomp>   s2    SSST++DKK,?,?@@SSSr   c                &    g | ]}|j         v |S r5   )r   )rJ   r?   rY   s     r   rK   z*Inventory.parse_sphinx.<locals>.<listcomp>   s%    LLLdt{m/K/KT/K/K/Kr   )rangereadlinerT   
decompressread
splitlines)r*   rZ   rY   _rX   r:   s     `   r   r,   zInventory.parse_sphinx   s     q 	 	A//::<<SSUSSS 	MLLLLeLLLEs5zzr   )Nr8   r9   )r:   r;   r8   r   r<   r   r-   )r
   r   r   r   r   r   r   r   r   r   r   r   r   rA   )r   rD   )rZ   r   rY   r[   r   r7   )
r.   r/   r0   r1   r   rC   r"   r4   r,   __classcell__)r@   s   @r   r7   r7   I   s        66      * #
 
 
 
 
8D D D D2 QS      [    r   r7   )r1   
__future__r   r2   rT   textwrapr   typingr   r   r   dictr7   r5   r   r   <module>rl      s    3 3
 # " " " " " 				        ' ' ' ' ' ' ' '8E 8E 8E 8E 8E 8E 8E 8EvX X X X X X X X X Xr   