
    f j                         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
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)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         sC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\openpyxl/packaging/relationship.py__init__zRelationship.__init__!   sA      	2##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                   V    e Zd ZdZ ee          ZddZd Zd Zd Z	d Z
d	 Zd
 ZdS )RelationshipListRelationships)expected_typer!   c                     || _         d S N)r   )r   r   s     r   r   zRelationshipList.__init__;   s    (r   c                     | j         d d          }|                    |           |j        s'd                    t	          |                    |_        || _         d S )NrId{0})r   appendr   r   len)r   valuevaluess      r   r*   zRelationshipList.append?   sV    "111%ex 	6F55EH"r   c                 *    t          | j                  S r'   )r+   r   r   s    r   __len__zRelationshipList.__len__G   s    4$%%%r   c                 *    t          | j                  S r'   )boolr   r/   s    r   __bool__zRelationshipList.__bool__K   s    D%&&&r   c              #   <   K   | j         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   )r   content_typers      r   findzRelationshipList.findO   s=       " 	 	Av% 	 	r   c                 x    | j         D ]}|j        |k    r|c S t          d                    |                    )NzUnknown relationship: {0})r   r   KeyErrorr   )r   keyr6   s      r   __getitem__zRelationshipList.__getitem__Z   sM    " 	 	Ats{ 299#>>???r   c                     t          dt                    }t          | j        d          D ]M\  }}|j        sd                    |          |_        |                    |                                           N|S )Nr$   )xmlns   r)   )r
   r	   	enumerater   r   r   r*   to_tree)r   treeidxrels       r   r@   zRelationshipList.to_treea   ss    j999!$"3Q77 	' 	'HC6 .!--KK&&&&r   N)r!   )r   r   r   r   r   r   r   r*   r0   r3   r7   r;   r@   r!   r   r   r#   r#   4   s        G8,777L) ) ) )# # #& & &' ' '  @ @ @    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_pathrM   k   s=     /$''KFC~fgz/@/@/E/EFFHOr   c                 V   |                      |          }t          |          }	 t                              |          }nB# t          $ r5 d                    |          }t          |           t                      }Y nw xY wt          j        |          }t          j	        |          d         }|j
        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/r>   N)readr   r#   	from_tree	TypeErrorr   r   rF   dirnamerG   r   r   r   
startswithrH   normpath)
archiverL   srcnoderelsmsgrJ   parentr6   pths
             r   get_dependentsr^   w   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
ValueErrornextr7   rel_typeStopIterationr   rQ   r   rR   rM   r^   depsr9   )
rW   re   r    clsrC   rI   rX   rA   rK   	rels_paths
             r   get_relrh      s    Cy>> KIJJJ	 2h	tyy..//CC 	 	 	FF	 :D
,,t

Cc??D
--

Cd##I!'955    Js#   'A 
A#"A#6C C C )NN)rF   warningsr   openpyxl.descriptorsr   r   r   !openpyxl.descriptors.serialisabler   openpyxl.xml.constantsr   r	   openpyxl.xml.functionsr
   r   r   r#   rM   r^   rh   r!   r   r   <module>rn      s=                     
 ; : : : : : 5 5 5 5 5 5 5 5           <   @4 4 4 4 4| 4 4 4n	 	 	  6     r   