
    fh                         d dl Z d dlmZ d dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZ d dlmZmZ  G d d	e          Z G d
 de
          Zd Zd ZddZdS )    N)warn)StringAliasSequence)Serialisable)ElementList)REL_NS
PKG_REL_NS)Element
fromstringc                       e Zd ZdZd Z e            Z e            Z ed          Z	 ed          Z
 ed          Z ed          Z	 	 	 	 	 ddZdS )	Relationshipz'Represents many kinds of relationships.TargetT)
allow_noneIdNc                 x    |d                     t          |          }|| _        || _        || _        || _        dS )z
        `type` can be used as a shorthand with the default relationships namespace
        otherwise the `Type` must be a fully qualified URL
        Nz{0}/{1})formatr	   Typer   
TargetModer   )selfr   r   typer   r   s         V/var/www/histauto/venv/lib/python3.11/site-packages/openpyxl/packaging/relationship.py__init__zRelationship.__init__"   s?     ##FD11D	$    )NNNNN)__name__
__module____qualname____doc__tagnamer   r   r   r   targetr   r   idr    r   r   r   r      s        11G688DVXXFU8__F4(((J	4	 	 	 B	tB       r   r   c                   B     e Zd ZdZeZ fdZd Zd Zd Z	 fdZ
 xZS )RelationshipListRelationshipsc                     t                                          |           |j        sdt          |            |_        d S d S )NrId)superappendr   len)r   value	__class__s     r   r)   zRelationshipList.append;   sF    ux 	)(SYY((EHHH	) 	)r   c              #   2   K   | D ]}|j         |k    r|V  dS )z
        Find relationships by content-type
        NB. these content-types namespaced objects and different to the MIME-types
        in the package manifest :-(
        N)r   )r   content_typers      r   findzRelationshipList.findA   s8        	 	Av%%	 	r   c                 n    | D ]}|j         |k    r|c S t          d                    |                    )NzUnknown relationship: {0})r   KeyErrorr   )r   keyr/   s      r   getzRelationshipList.getL   sG     	 	Ats{{ 299#>>???r   c                     d | D             S )z,Return a dictionary of relations keyed by idc                     i | ]
}|j         |S r"   )r!   ).0r/   s     r   
<dictcomp>z,RelationshipList.to_dict.<locals>.<dictcomp>U   s    %%%1Q%%%r   r"   )r   s    r   to_dictzRelationshipList.to_dictS   s    %%%%%%r   c                 ~    t                                                      }|                    dt                     |S )Nxmlns)r(   to_treesetr
   )r   treer,   s     r   r<   zRelationshipList.to_treeX   s/    ww  *%%%r   )r   r   r   r   r   expected_typer)   r0   r4   r9   r<   __classcell__)r,   s   @r   r$   r$   5   s        G M) ) ) ) )  @ @ @& & &
        r   r$   c                     t          j        |           \  }}t          j        |dd                    |                    }|S )z
    Convert relative path to absolutes that can be loaded from a zip
    archive.
    The path to be passed in is that of containing object (workbook,
    worksheet, etc.)
    _relsz{0}.rels)	posixpathsplitjoinr   )pathfolderobjfilenames       r   get_rels_pathrJ   ^   s=     /$''KFC~fgz/@/@/E/EFFHOr   c                 L   |                      |          }t          |          }	 t                              |          }nB# t          $ r5 d                    |          }t          |           t                      }Y nw xY wt          j        |          }t          j	        |          d         }|D ]p}|j
        dk    r|j                            d          r|j        dd         |_        =t          j        ||j                  }	t          j        |	          |_        q|S )zl
    Normalise dependency file paths to absolute ones

    Relative paths are relative to parent object
    z+{0} contains invalid dependency definitionsr   External/   N)readr   r$   	from_tree	TypeErrorr   r   rC   dirnamerD   r   r    
startswithrE   normpath)
archiverI   srcnoderelsmsgrG   parentr/   pths
             r   get_dependentsr\   j   s    ,,x
 
 Cc??D"))$// " " ";BB8LLS			!!" x((F_V$$Q'F / /<:%%X  %% 	/x|AHH.22C )#..AHHKs   A <B ?B c                    t          ||g          st          d          ||                    |          }n:	 t          |                    |j                            }n# t          $ r Y dS w xY w|j        }|                     |          }t          |          }|
                    |          }t          |          }		 t          | |	          |_        n# t          $ r
 g |_        Y nw xY w|S )z4
    Get related object based on id or rel_type
    z.Either the id or the content type are requiredN)any
ValueErrorr4   nextr0   rel_typeStopIterationr    rO   r   rP   rJ   r\   depsr2   )
rU   rc   r!   clsrelrF   rV   r>   rH   	rels_paths
             r   get_relrg      s    Cy>> KIJJJ	~hhrll	tyy..//CC 	 	 	FF	 :D
,,t

Cc??D
--

Cd##I!'955    Js#   'A" "
A0/A0C C-,C-)NN)rC   warningsr   openpyxl.descriptorsr   r   r   !openpyxl.descriptors.serialisabler   openpyxl.descriptors.containerr   openpyxl.xml.constantsr	   r
   openpyxl.xml.functionsr   r   r   r$   rJ   r\   rg   r"   r   r   <module>rn      sO                     
 ; : : : : : 6 6 6 6 6 6 5 5 5 5 5 5 5 5           <   @& & & & &{ & & &R	 	 	  6     r   