| 675 | |
| 676 | |
| 677 | class 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 | |
| 715 | class ChoiceEncoder(AbstractItemEncoder): |