f0 ddlmZddlmZmZmZmZmZddlm Z  dZ dZ dZ dZ dZ er ddlmZdd lmZGd d Zej(Z ej*Z ej,Z ej.Z e efZej2ej(ej*ej,ej.fZej2d ej(d ej*dej,dej.diZdZ dZ dZ dZ Gdde Z!y)) annotations) TYPE_CHECKINGAnyTupleTypeUnion)UUID)array)mmapc(eZdZdZ eZ eZ dZ dZ y)UuidRepresentationrN) __name__ __module__ __qualname__ UNSPECIFIED UUID_SUBTYPESTANDARDOLD_UUID_SUBTYPE PYTHON_LEGACY JAVA_LEGACY CSHARP_LEGACYT/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/bson/binary.pyrrBs<K H %M K M rrzUuidRepresentation.UNSPECIFIEDzUuidRepresentation.STANDARDz UuidRepresentation.PYTHON_LEGACYzUuidRepresentation.JAVA_LEGACYz UuidRepresentation.CSHARP_LEGACYrceZdZUdZdZded<ef ddZee jf ddZ e jfddZ e ddZdfd Zdd Zdfd Zdd Zdd ZxZS)BinaryaRepresentation of BSON binary data. This is necessary because we want to represent Python strings as the BSON string type. We need to wrap binary data so we can tell the difference between what should be considered binary data and what should be considered a string when we encode to BSON. Raises TypeError if `data` is not an instance of :class:`bytes` or `subtype` is not an instance of :class:`int`. Raises ValueError if `subtype` is not in [0, 256). .. note:: Instances of Binary with subtype 0 will be decoded directly to :class:`bytes`. :param data: the binary data to represent. Can be any bytes-like type that implements the buffer protocol. :param subtype: the `binary subtype `_ to use .. versionchanged:: 3.9 Support any bytes-like type that implements the buffer protocol. rint_Binary__subtypect|ts td|dk\s|dkr tdtj |t |j}||_|S)Nz"subtype must be an instance of intrz%subtype must be contained in [0, 256)) isinstancer& TypeError ValueErrorbytes__new__ memoryviewtobytesr')clsdatasubtypeselfs r r.zBinary.__new__s] '3'@A A c>Wq[DE E}}S*T"2":":"<=  rct|ts td|tvr t d|t j k(r t dt}|t jk(r |j}ni|t jk(r$|j}|ddddd|dddddz}n2|t jk(r |j}nt}|j}|||S) aCreate a BSON Binary object from a Python UUID. Creates a :class:`~bson.binary.Binary` object from a :class:`uuid.UUID` instance. Assumes that the native :class:`uuid.UUID` instance uses the byte-order implied by the provided ``uuid_representation``. Raises :exc:`TypeError` if `uuid` is not an instance of :class:`~uuid.UUID`. :param uuid: A :class:`uuid.UUID` instance. :param uuid_representation: A member of :class:`~bson.binary.UuidRepresentation`. Default: :const:`~bson.binary.UuidRepresentation.STANDARD`. See :ref:`handling-uuid-data-example` for details. .. versionadded:: 3.11 z%uuid must be an instance of uuid.UUIDGuuid_representation must be a value from bson.binary.UuidRepresentationacannot encode native uuid.UUID with UuidRepresentation.UNSPECIFIED. UUIDs can be manually converted to bson.Binary instances using bson.Binary.from_uuid() or a different UuidRepresentation can be configured. See the documentation for UuidRepresentation for more information.rr"N)r*r r+ALL_UUID_REPRESENTATIONSr,rrrrr-rrbytes_ler)r1uuiduuid_representationr3payload from_uuids r r>zBinary.from_uuids,$%CD D &> >Y  "4"@"@ @; # "4"B"B BjjG $6$B$B B I!nTrT*Yq_TrT-BBG $6$D$D DmmG#GjjG7G$$rc|jtvrtd|jd|tvr td|tj k(r td|tj k(r|jtk(rt|S|tjk(r4|jtk(rrt|ddddd |dd ddd zS|tjk(r|jtk(r+t| S|jtk(r t|Std|jd t|) a9Create a Python UUID from this BSON Binary object. Decodes this binary object as a native :class:`uuid.UUID` instance with the provided ``uuid_representation``. Raises :exc:`ValueError` if this :class:`~bson.binary.Binary` instance does not contain a UUID. :param uuid_representation: A member of :class:`~bson.binary.UuidRepresentation`. Default: :const:`~bson.binary.UuidRepresentation.STANDARD`. See :ref:`handling-uuid-data-example` for details. .. versionadded:: 3.11 zcannot decode subtype z as a uuidr6z)uuid_representation cannot be UNSPECIFIED)r-rr"Nr7r8)r:z to ) r3ALL_UUID_SUBTYPESr,r9rrrrr rrrUUID_REPRESENTATION_NAMES)r4r<s r as_uuidzBinary.as_uuid(s9 <<0 05dll^:NO O &> >Y  "4"@"@ @HI I $6$D$D D||//$'' $6$B$B B||//$q)DbD/D2Jtt4D"DEE $6$D$D D||//T**|||+$''$T\\N$7PQd7e6f g  rc|jS)zSubtype of this binary data.)r'r4s r r3zBinary.subtypeTs~~rct|d}t|ts|j d}||j fS)Nrzlatin-1)super__getnewargs__r*r-encoder')r4r2 __class__s r rGzBinary.__getnewargs__Ys<w%'*$&;;y)DT^^##rct|tr/|jt|f|jt|fk(Sy)NF)r*r%r'r-r3r4others r __eq__z Binary.__eq__`s6 eV $NNE$K0U]]E%L4QQ QrcLt|t|jz SN)rF__hash__hashr')r4rIs r rPzBinary.__hash__hsw!D$888rc||k( SrOrrKs r __ne__z Binary.__ne__ks5=  rc|jtk(rd|jdSdtj|d|jdS)NzzBinary(z, ))r'SENSITIVE_SUBTYPEr-__repr__rDs r rWzBinary.__repr__nsG >>. .''7r: :U^^D12"T^^4DAF Fr)r1 Type[Binary]r2z,Union[memoryview, bytes, _mmap, _array[Any]]r3r&returnr%)r1rXr;r r<r&rYr%)r<r&rYr )rYr&)rYzTuple[bytes, int])rLrrYbool)rYstr)rrr__doc__ _type_marker__annotations__BINARY_SUBTYPEr. classmethodrrr>rBpropertyr3rGrMrPrSrW __classcell__)rIs@r r%r%s0LN &   :    BTB]B]4% 4%!%4%rls#99    %"@@F  & & #00  !,, #00 &|4""$$""$$ ""$D!>$$&H""$D$$&H    kGUkGr