MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / SequenceOfEncoder

Class SequenceOfEncoder

pager_lib/pyasn1/codec/ber/encoder.py:677–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675
676
677class SequenceOfEncoder(AbstractItemEncoder):
678 def _encodeComponents(self, value, asn1Spec, encodeFun, **options):
679
680 if asn1Spec is None:
681 inconsistency = value.isInconsistent
682 if inconsistency:
683 raise error.PyAsn1Error(
684 f"ASN.1 object {value.__class__.__name__} is inconsistent")
685
686 else:
687 asn1Spec = asn1Spec.componentType
688
689 chunks = []
690
691 wrapType = options.pop('wrapType', None)
692
693 for idx, component in enumerate(value):
694 chunk = encodeFun(component, asn1Spec, **options)
695
696 if (wrapType is not None and
697 not wrapType.isSameTypeWith(component)):
698 # wrap encoded value with wrapper container (e.g. ANY)
699 chunk = encodeFun(chunk, wrapType, **options)
700
701 if LOG:
702 LOG('wrapped with wrap type %r' % (wrapType,))
703
704 chunks.append(chunk)
705
706 return chunks
707
708 def encodeValue(self, value, asn1Spec, encodeFun, **options):
709 chunks = self._encodeComponents(
710 value, asn1Spec, encodeFun, **options)
711
712 return b''.join(chunks), True, True
713
714
715class ChoiceEncoder(AbstractItemEncoder):

Callers 1

encoder.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected