"""
from array import array
-from codecs import getdecoder
-from codecs import getencoder
from collections import namedtuple
from collections import OrderedDict
from copy import copy
def colored(what, *args, **kwargs):
return what
-__version__ = "9.0"
+try:
+ from dateutil.tz import UTC as tzUTC
+except ImportError: # pragma: no cover
+ tzUTC = "missing"
+
+
+__version__ = "9.1"
__all__ = (
"agg_octet_string",
# Basic coders
########################################################################
-_hexdecoder = getdecoder("hex")
-_hexencoder = getencoder("hex")
-
-
def hexdec(data):
"""Binary data to hexadecimal string convert
"""
- return _hexdecoder(data)[0]
+ return bytes.fromhex(data)
def hexenc(data):
"""Hexadecimal string to binary data convert
"""
- return _hexencoder(data)[0].decode("ascii")
+ return data.hex()
def int_bytes_len(num, byte_len=8):
def todatetime(self):
return self._value
+ def totzdatetime(self):
+ try:
+ return self._value.replace(tzinfo=tzUTC)
+ except TypeError as err:
+ raise NotImplementedError(
+ "Package python-dateutil is required to use this feature",
+ ) from err
+
def __repr__(self):
return pp_console_row(next(self.pps()))
)
-class SequenceEncode1stMixing:
+class SequenceEncode1stMixin:
__slots__ = ()
def _encode1st(self, state):
return len(self.tag) + len_size(vlen) + vlen, state
-class Sequence(SequenceEncode1stMixing, Obj):
+class Sequence(SequenceEncode1stMixin, Obj):
"""``SEQUENCE`` structure type
You have to make specification of sequence::
yield pp
-class Set(Sequence, SequenceEncode1stMixing):
+class Set(Sequence, SequenceEncode1stMixin):
"""``SET`` structure type
Its usage is identical to :py:class:`pyderasn.Sequence`.
)
-class SequenceOf(SequenceEncode1stMixing, Obj):
+class SequenceOf(SequenceEncode1stMixin, Obj):
"""``SEQUENCE OF`` sequence type
For that kind of type you must specify the object it will carry on