try:
from termcolor import colored
-except ImportError:
+except ImportError: # pragma: no cover
def colored(what, *args):
return what
"""
raise NotImplementedError()
+ def _assert_ready(self):
+ if not self.ready:
+ raise ObjNotReady(self.__class__.__name__)
+
@property
def bered(self):
"""Is either object or any elements inside is BER encoded?
"""
return self.expl_lenindef or self.lenindef or self.ber_encoded
- def _assert_ready(self):
- if not self.ready:
- raise ObjNotReady(self.__class__.__name__)
-
@property
def decoded(self):
"""Is object decoded?
ctx=ctx,
tag_only=tag_only,
)
- if tag_only:
+ if tag_only: # pragma: no cover
return
obj, tail = result
eoc_expected, tail = tail[:EOC_LEN], tail[EOC_LEN:]
ctx=ctx,
tag_only=tag_only,
)
- if tag_only:
+ if tag_only: # pragma: no cover
return
obj, tail = result
if obj.tlvlen < l and not ctx.get("allow_expl_oob", False):
return self.expl_tlvlen if self.expled else self.tlvlen
def pps_lenindef(self, decode_path):
- if self.lenindef:
+ if self.lenindef and not (
+ getattr(self, "defined", None) is not None and
+ self.defined[1].lenindef
+ ):
yield _pp(
asn1_type_name="EOC",
obj_name="",
offset=offset,
)
if t == self.tag:
- if tag_only:
+ if tag_only: # pragma: no cover
return
return self._decode_chunk(lv, offset, decode_path, ctx)
if t == self.tag_constructed:
decode_path=decode_path,
offset=offset,
)
- if tag_only:
+ if tag_only: # pragma: no cover
return
lenindef = False
try:
decode_path=decode_path,
offset=offset,
)
- if tag_only:
+ if tag_only: # pragma: no cover
return
try:
l, _, v = len_decode(lv)
decode_path=decode_path,
offset=offset,
)
- if tag_only:
+ if tag_only: # pragma: no cover
return
try:
l, llen, v = len_decode(lv)
decode_path=decode_path,
offset=offset,
)
- if tag_only:
+ if tag_only: # pragma: no cover
return
value, tail = spec.decode(
tlv,
_decoded=(offset, 0, value.fulllen),
)
obj._value = (choice, value)
- obj.lenindef = value.lenindef
- obj.ber_encoded = value.ber_encoded
return obj, tail
def __repr__(self):
llen=self.llen,
vlen=self.vlen,
expl_lenindef=self.expl_lenindef,
- lenindef=self.lenindef,
- ber_encoded=self.ber_encoded,
bered=self.bered,
)
if self.ready:
decode_path=decode_path,
offset=offset,
)
- if tag_only:
+ if tag_only: # pragma: no cover
return
lenindef = False
ctx_bered = ctx.get("bered", False)