
    <i                     T    S r SSKJr  SSKJr  SSKJr  S rS rS r	S r
S	 rSS jrg
)z1Functions for working with STIX2 object markings.    )
exceptions)utilsnew_versionc                 &    U R                  S/ 5      $ )z
Get all object level markings from the given SDO or SRO object.

Args:
    obj: A SDO or SRO object.

Returns:
    list: Marking identifiers contained in the SDO or SRO. Empty list if no
        markings are present in `object_marking_refs`.

object_marking_refs)getobjs    X/home/james-whalen/.local/lib/python3.13/site-packages/stix2/markings/object_markings.pyget_markingsr      s     77("--    c                     [         R                  " U5      n[        U R                  S/ 5      U-   5      n[	        U [        U5      SS9$ )a  
Append an object level marking to the object_marking_refs collection.

Args:
    obj: A SDO or SRO object.
    marking: identifier or list of identifiers to apply SDO or SRO object.

Returns:
    A new version of the given SDO or SRO with specified markings added.

r   Tr   allow_custom)r   convert_to_marking_listsetr	   r   listr   markingobject_markingss      r   add_markingsr      sD     ++G4G#''"7<wFGOs_0ETXYYr   c                 >  ^  [         R                  " U5      nT R                  S/ 5      nU(       d  T $ [        U 4S jU 5       5      (       a  [        R
                  " T U5      eU Vs/ s H  o3U;  d  M
  UPM     nnU(       a  [        T USS9$ [        T SSS9$ s  snf )a  
Remove an object level marking from the object_marking_refs collection.

Args:
    obj: A SDO or SRO object.
    marking: identifier or list of identifiers that apply to the
        SDO or SRO object.

Raises:
    MarkingNotFoundError: If markings to remove are not found on
        the provided SDO or SRO.

Returns:
    A new version of the given SDO or SRO with specified markings removed.

r   c              3   2   >#    U  H  oTS    ;  v   M     g7f)r   N ).0xr   s     r   	<genexpr>"remove_markings.<locals>.<genexpr>B   s     
@1C-..s   Tr   N)r   r   r	   anyr   MarkingNotFoundErrorr   )r   r   r   r   new_markingss   `    r   remove_markingsr#   *   s    " ++G4Ggg3R8O


@
@@@--c7;;.C!72BALC3LtTT3DtLL	 Ds   (	B5Bc                 ,    [        [        U 5      U5      $ )a  
Remove all object level markings and append new object level markings to
the collection. Refer to `clear_markings` and `add_markings` for details.

Args:
    obj: A SDO or SRO object.
    marking: identifier or list of identifiers to apply in the
        SDO or SRO object.

Returns:
    A new version of the given SDO or SRO with specified markings removed
    and new ones added.

)r   clear_markings)r   r   s     r   set_markingsr&   L   s     s+W55r   c                     [        U SSS9$ )z
Remove all object level markings from the object_marking_refs collection.

Args:
    obj: A SDO or SRO object.

Returns:
    A new version of the given SDO or SRO with object_marking_refs cleared.

NTr   r   r
   s    r   r%   r%   ^   s     s4HHr   Nc                    ^ [         R                  " U5      nU R                  S/ 5      mU(       a  [        U4S jU 5       5      $ [	        T5      $ )a  
Check if SDO or SRO is marked by any marking or by specific marking(s).

Args:
    obj: A SDO or SRO object.
    marking: identifier or list of marking identifiers that apply to the
        SDO or SRO object.

Returns:
    bool: True if SDO or SRO has object level markings. False otherwise.

Note:
    When an identifier or list of identifiers is provided, if ANY of the
    provided marking refs match, True is returned.

r   c              3   ,   >#    U  H	  oT;   v   M     g 7fNr   )r   r   r   s     r   r   is_marked.<locals>.<genexpr>   s     9A's   )r   r   r	   r    boolr   s     @r   	is_markedr-   l   sE    " ++G4Ggg3R8O9999O$$r   r*   )__doc__stix2r   stix2.markingsr   stix2.versioningr   r   r   r#   r&   r%   r-   r   r   r   <module>r2      s3    7    (.Z&MD6$I%r   