
    ܖirH                     
   d Z ddlmZ ddlmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlZddlmZ d	d
lmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZmZm Z  ddl!m"Z"m#Z# ddl$m%Z% ejL                   G d de'e             Z(e(Z)	  ejT                  dd       G d d             Z+ ejT                  dd       G d d             Z,e
e,e+f   Z-	 er G d dee-         Z.n G d de      Z. G d d ej^                  j`                        Z1y)!z
License related things
    )Enum)loads)TYPE_CHECKINGAnyOptionalUnion)warn)ElementN)	SortedSet   )bom_ref_from_str)ComparableTuple)$MutuallyExclusivePropertiesException)!CycloneDxDeserializationException)SchemaVersion1Dot5SchemaVersion1Dot6SchemaVersion1Dot7   )AttachedTextXsUri)BomRefc                       e Zd ZdZdZdZy)LicenseAcknowledgementaW  
    This is our internal representation of the `type_licenseAcknowledgementEnumerationType` ENUM type
    within the CycloneDX standard.

    .. note::
        Introduced in CycloneDX v1.6

    .. note::
        See the CycloneDX Schema for hashType:
        https://cyclonedx.org/docs/1.7/xml/#type_licenseAcknowledgementEnumerationType
    	concludeddeclaredN)__name__
__module____qualname____doc__	CONCLUDEDDECLARED     [/var/www/html/content-pipeline/venv/lib/python3.12/site-packages/cyclonedx/model/license.pyr   r   )   s    
 IHr#   r   licenseT)name%ignore_unknown_during_deserializationc                      e Zd ZdZddddddddeeeef      dee   dee   dee   dee	   d	ee
   d
dfdZe ej                  e       ej                  e       ej                  e       ej$                  e       ej&                          ej(                  d       ej*                  d      d
efd                                                        Ze ej.                  d      d
ee   fd              Zej2                  dee   d
dfd       Ze ej.                  d       ej4                  ej6                  j8                        d
ee   fd                     Zej2                  dee   d
dfd       Ze ej.                  d      d
ee   fd              Zej2                  dee   d
dfd       Ze ej.                  d      d
ee	   fd              Zej2                  dee	   d
dfd       Ze ej                  e       ej                  e       ej&                         d
ee
   fd                            Z e j2                  d	ee
   d
dfd       Z d
e!fdZ"de#d
e$fdZ%de&d
e$fdZ'd
e(fdZ)d
efd Z*y)!DisjunctiveLicensea  
    This is our internal representation of `licenseType` complex type that can be used in multiple places within
    a CycloneDX BOM document.

    .. note::
        See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.7/xml/#type_licenseType
    N)bom_refidr&   texturlacknowledgementr*   r+   r&   r,   r-   r.   returnc                    |s|st        d      |r|rt        dt        d       t        |      | _        || _        |s|nd | _        || _        || _        || _	        y )Nz&Either `id` or `name` MUST be suppliedzABoth `id` and `name` have been supplied - `name` will be ignored!r   )category
stacklevel)
r   r	   RuntimeWarning_bom_ref_from_str_bom_ref_id_name_text_url_acknowledgement)selfr*   r+   r&   r,   r-   r.   s          r$   __init__zDisjunctiveLicense.__init__R   s`     $67_``$S'A *'2!#T

	 /r#   bom-refc                     | j                   S z
        An optional identifier which can be used to reference the component elsewhere in the BOM. Every bom-ref MUST be
        unique within the BOM.

        Returns:
            `BomRef`
        r5   r;   s    r$   r*   zDisjunctiveLicense.bom_refg         }}r#   r   c                     | j                   S )z
        A SPDX license ID.

        .. note::
          See the list of expected values:
          https://cyclonedx.org/docs/1.7/json/#components_items_licenses_items_license_id

        Returns:
            `str` or `None`
        )r6   rA   s    r$   r+   zDisjunctiveLicense.idy   s     xxr#   c                 &    || _         |d | _        y y Nr6   r7   )r;   r+   s     r$   r+   zDisjunctiveLicense.id   s    >DJ r#   c                     | j                   S )z
        If SPDX does not define the license used, this field may be used to provide the license name.

        Returns:
            `str` or `None`
        )r7   rA   s    r$   r&   zDisjunctiveLicense.name   s     zzr#   c                 &    || _         |d | _        y y rE   )r7   r6   )r;   r&   s     r$   r&   zDisjunctiveLicense.name   s    
DH r#   r   c                     | j                   S )z}
        Specifies the optional full text of the attachment

        Returns:
            `AttachedText` else `None`
        r8   rA   s    r$   r,   zDisjunctiveLicense.text   s     zzr#   c                     || _         y rE   rJ   )r;   r,   s     r$   r,   zDisjunctiveLicense.text   s	    
r#      c                     | j                   S )z
        The URL to the attachment file. If the attachment is a license or BOM, an externalReference should also be
        specified for completeness.

        Returns:
            `XsUri` or `None`
        r9   rA   s    r$   r-   zDisjunctiveLicense.url   s     yyr#   c                     || _         y rE   rN   )r;   r-   s     r$   r-   zDisjunctiveLicense.url   s	    	r#   c                     | j                   S a  
        Declared licenses and concluded licenses represent two different stages in the licensing process within
        software development.

        Declared licenses refer to the initial intention of the software authors regarding the
        licensing terms under which their code is released. On the other hand, concluded licenses are the result of a
        comprehensive analysis of the project's codebase to identify and confirm the actual licenses of the components
        used, which may differ from the initially declared licenses. While declared licenses provide an upfront
        indication of the licensing intentions, concluded licenses offer a more thorough understanding of the actual
        licensing within a project, facilitating proper compliance and risk management. Observed licenses are defined
        in evidence.licenses. Observed licenses form the evidence necessary to substantiate a concluded license.

        Returns:
            `LicenseAcknowledgement` or `None`
        r:   rA   s    r$   r.   z"DisjunctiveLicense.acknowledgement       ( $$$r#   c                     || _         y rE   rR   r;   r.   s     r$   r.   z"DisjunctiveLicense.acknowledgement   
     /r#   c                     t        | j                  | j                  | j                  | j                  | j
                  | j                  j                  f      S rE   )_ComparableTupler:   r6   r7   r9   r8   r5   valuerA   s    r$   __comparable_tuplez%DisjunctiveLicense.__comparable_tuple   sE    !!HHdjjIIJJMM!
  	r#   otherc                 f    t        |t              r!| j                         |j                         k(  S yNF)
isinstancer)   %_DisjunctiveLicense__comparable_tupler;   r[   s     r$   __eq__zDisjunctiveLicense.__eq__   s-    e/0**,0H0H0JJJr#   c                     t        |t              r!| j                         |j                         k  S t        |t              ryt        S r]   )r^   r)   r_   LicenseExpressionNotImplementedr`   s     r$   __lt__zDisjunctiveLicense.__lt__   s>    e/0**,u/G/G/IIIe./r#   c                 4    t        | j                               S rE   )hashr_   rA   s    r$   __hash__zDisjunctiveLicense.__hash__      D++-..r#   c                 <    d| j                   d| j                  dS )Nz<License id=z, name=>rF   rA   s    r$   __repr__zDisjunctiveLicense.__repr__	  s    dhh\a@@r#   )+r   r   r   r   r   r   strr   r   r   r   r<   propertyserializableviewr   r   r   type_mappingxml_attributexml_name	json_namer*   xml_sequencer+   setter
xml_stringXmlStringSerializationTypeNORMALIZED_STRINGr&   r,   r-   r.   rX   r_   objectboolra   r   re   intrh   rl   r"   r#   r$   r)   r)   E   s   
 15 '+D<@0%V,-0 SM0 )10 |$	0 3;5/	0
 ""890 
0* \)*\)*\)*\v&\!\9%\I&  ' & " ' + + +  \q!HSM  "  YYXc] t  
 \q!\\DDVVWhsm  X "  
[[# 4  
 \q!h|,  "  
[[,/ D   \q!Xe_  "  	ZZx 4  6 \)*\)*\!%*@!A % " + + %$ 0x8N/O 0TX 0 0$4 F t 
C D /# /A# Ar#   r)   
expressionc            
       z   e Zd ZdZddddedeeeef      dee   ddfdZ	e
 ej                  e       ej                  e       ej                  e       ej                   e       ej"                          ej$                  d	       ej&                  d	      defd
                                                        Ze
 ej$                  d       ej*                  ej,                  j.                         ej&                  d      defd                            Zej2                  deddfd       Ze
 ej                  e       ej                  e       ej"                         dee   fd                            Zej2                  dee   ddfd       ZdefdZdefdZdede fdZ!de"de fdZ#defdZ$y)rc   a.  
    This is our internal representation of `licenseType`'s  expression type that can be used in multiple places within
    a CycloneDX BOM document.

    .. note::
        See the CycloneDX Schema definition:
        https://cyclonedx.org/docs/1.7/json/#components_items_licenses_items_expression
    N)r*   r.   rY   r*   r.   r/   c                @    t        |      | _        || _        || _        y rE   )r4   r5   _valuer:   )r;   rY   r*   r.   s       r$   r<   zLicenseExpression.__init__  s    
 *'2 /r#   r=   c                     | j                   S r?   r@   rA   s    r$   r*   zLicenseExpression.bom_ref$  rB   r#   .r}   c                     | j                   S )zW
        Value of this LicenseExpression.

        Returns:
             `str`
        r   rA   s    r$   rY   zLicenseExpression.value6  s     {{r#   c                     || _         y rE   r   )r;   rY   s     r$   rY   zLicenseExpression.valueC  s	    r#   c                     | j                   S rQ   rR   rA   s    r$   r.   z!LicenseExpression.acknowledgementG  rS   r#   c                     || _         y rE   rR   rU   s     r$   r.   z!LicenseExpression.acknowledgement]  rV   r#   c                 n    t        | j                  | j                  | j                  j                  f      S rE   )rX   r:   r   r5   rY   rA   s    r$   rZ   z$LicenseExpression.__comparable_tuplea  s1    !!KKMM!
  	r#   c                 4    t        | j                               S rE   )rg   $_LicenseExpression__comparable_tuplerA   s    r$   rh   zLicenseExpression.__hash__h  ri   r#   r[   c                 f    t        |t              r!| j                         |j                         k(  S yr]   )r^   rc   r   r`   s     r$   ra   zLicenseExpression.__eq__k  s-    e./**,0H0H0JJJr#   c                     t        |t              r!| j                         |j                         k  S t        |t              ryt        S )NT)r^   rc   r   r)   rd   r`   s     r$   re   zLicenseExpression.__lt__p  s>    e./**,u/G/G/IIIe/0r#   c                 "    d| j                   dS )Nz<LicenseExpression value=rk   r   rA   s    r$   rl   zLicenseExpression.__repr__w  s    *4;;/;;r#   )%r   r   r   r   rm   r   r   r   r   r<   rn   ro   rp   r   r   r   rq   rr   rs   rt   r*   rw   rx   ry   rY   rv   r.   rX   r   r|   rh   rz   r{   ra   r   re   rl   r"   r#   r$   rc   rc     sb   
 15<@00%V,-0 ""890 
	0 \)*\)*\)*\v&\!\9%\I&  ' & " ' + + +  \3\\DDVVW\L)s  * X    \\3 4   \)*\)*\!%*@!A % " + + %$ 0x8N/O 0TX 0 0$4 /# /F t 
C D <# <r#   rc   c                       e Zd ZdZyLicenseRepositorya  Collection of :class:`License`.

        This is a `set`, not a `list`.  Order MUST NOT matter here.
        If you wanted a certain order, then you should also express whether the items are concat by `AND` or `OR`.
        If you wanted to do so, you should use :class:`LicenseExpression`.

        As a model, this MUST accept multiple :class:`LicenseExpression` along with
        multiple :class:`DisjunctiveLicense`, as this was an accepted in CycloneDX JSON before v1.5.
        So for modeling purposes, this is supported.
        Denormalizers/deserializers will be thankful.
        The normalization/serialization process SHOULD take care of these facts and do what is needed.
        Nr   r   r   r   r"   r#   r$   r   r         	r#   r   c                       e Zd ZdZyr   r   r"   r#   r$   r   r     r   r#   c                       e Zd ZdZededeeej                        de
de
fd       Zedeeee
f      de
defd       Zedededeeej                        d	ee   de
dee   fd
       Zededee   de
defd       Zy)%_LicenseRepositorySerializationHelperz   THIS CLASS IS NON-PUBLIC API  orp   __r/   c          	         t        |      dk(  ry t        d |D        d       }|rt        |j                  |            gS |D cg c]/  }t	        |t
              rdt        |j                  |            i1 c}S c c}w )Nr   c              3   B   K   | ]  }t        |t              s|  y wrE   r^   rc   .0lis     r$   	<genexpr>zG_LicenseRepositorySerializationHelper.json_normalize.<locals>.<genexpr>       O"Z<M-N2O   )view_r%   )lennext
json_loadsas_jsonr^   r)   )clsr   rp   r   r}   r   s         r$   json_normalizez4_LicenseRepositorySerializationHelper.json_normalize  s     q6Q;OOQUV
 z111=>?? 

 "01 


    
 	
 
s   4A<c                     t               }|D ]d  }d|v r(|j                  t        j                  |d                /d|v r%|j                  t        j                  |             Xt        d|       |S )Nr%   r}   unexpected: )r   addr)   	from_jsonrc   r   )r   r   r   repor   s        r$   json_denormalizez6_LicenseRepositorySerializationHelper.json_denormalize  s     !" 		OBB+55yM# $#*44  8,rf8MNN		O r#   element_namexmlnsc                    t        |      dk(  ry t        |      }t        d |D        d       }|r&|j                  |j	                  dd             |S |j                  fd|D               |S )Nr   c              3   B   K   | ]  }t        |t              s|  y wrE   r   r   s     r$   r   zF_LicenseRepositorySerializationHelper.xml_normalize.<locals>.<genexpr>  r   r   Fr}   r   	as_stringr   r   c              3   h   K   | ])  }t        |t              r|j                  d d       + yw)Fr%   r   N)r^   r)   as_xml)r   r   rp   r   s     r$   r   zF_LicenseRepositorySerializationHelper.xml_normalize.<locals>.<genexpr>  s>       b"45 		%iu  Vs   /2)r   r
   r   appendr   extend)r   r   r   rp   r   r   elemr}   s      ``   r$   xml_normalizez3_LicenseRepositorySerializationHelper.xml_normalize  s     q6Q;|$OOQUV
 KK
))e,e * U V  KK    r#   
default_nsc                 J   t               }|D ]  }||j                  n|j                  j                  d| dd      }|dk(  r&|j                  t        j                  ||             \|dk(  r&|j                  t        j                  ||             t        d|       |S )N{} r%   r}   r   )r   tagreplacer   r)   from_xmlrc   r   )r   r   r   r   r   r   r   s          r$   xml_denormalizez5_LicenseRepositorySerializationHelper.xml_denormalize  s     !" 		OB&."&&BFFNNR
|SUCVXZ4[Ci+44
$ %$*33
$ % 8,rf8MNN		O r#   N)r   r   r   r   classmethodr   r   typero   ViewTyper   r   listdictrm   r   r
   r   r   r"   r#   r$   r   r     s   *
0 
%d<+@+@&AB
 
%(
 
( d38n!5 "'8  / $'$T,*?*?%@A &c]  	 %-W$5	 0  $,SM!&7 r#   r   )2r   enumr   jsonr   r   typingr   r   r   r   warningsr	   xml.etree.ElementTreer
   py_serializablero   sortedcontainersr   _internal.bom_refr   r4   _internal.comparer   rX   exception.modelr   exception.serializationr   schema.schemar   r   r   r   r   r   r*   r   serializable_enumrm   r    LicenseExpressionAcknowledgementserializable_classr)   rc   Licenser   helpers
BaseHelperr   r"   r#   r$   <module>r      s#  &  $ 6 6  ) & & E C B G V V !  S$   & $:   !  	*.AA AA	AAH !  	*.g< g<	g<T !#55
6 Ig. I PL,@,@,K,K Pr#   