(self, value, asn1Spec=None, **options)
| 822 | self._typeMap = typeMap if typeMap is not _MISSING else self.TYPE_MAP |
| 823 | |
| 824 | def __call__(self, value, asn1Spec=None, **options): |
| 825 | try: |
| 826 | if asn1Spec is None: |
| 827 | typeId = value.typeId |
| 828 | else: |
| 829 | typeId = asn1Spec.typeId |
| 830 | |
| 831 | except AttributeError: |
| 832 | raise error.PyAsn1Error('Value %r is not ASN.1 type instance ' |
| 833 | 'and "asn1Spec" not given' % (value,)) |
| 834 | |
| 835 | if LOG: |
| 836 | LOG('encoder called in %sdef mode, chunk size %s for type %s, ' |
| 837 | 'value:\n%s' % (not options.get('defMode', True) and 'in' or '', |
| 838 | options.get('maxChunkSize', 0), |
| 839 | asn1Spec is None and value.prettyPrintType() or |
| 840 | asn1Spec.prettyPrintType(), value)) |
| 841 | |
| 842 | if self.fixedDefLengthMode is not None: |
| 843 | options.update(defMode=self.fixedDefLengthMode) |
| 844 | |
| 845 | if self.fixedChunkSize is not None: |
| 846 | options.update(maxChunkSize=self.fixedChunkSize) |
| 847 | |
| 848 | try: |
| 849 | concreteEncoder = self._typeMap[typeId] |
| 850 | |
| 851 | if LOG: |
| 852 | LOG('using value codec %s chosen by type ID ' |
| 853 | '%s' % (concreteEncoder.__class__.__name__, typeId)) |
| 854 | |
| 855 | except KeyError: |
| 856 | if asn1Spec is None: |
| 857 | tagSet = value.tagSet |
| 858 | else: |
| 859 | tagSet = asn1Spec.tagSet |
| 860 | |
| 861 | # use base type for codec lookup to recover untagged types |
| 862 | baseTagSet = tag.TagSet(tagSet.baseTag, tagSet.baseTag) |
| 863 | |
| 864 | try: |
| 865 | concreteEncoder = self._tagMap[baseTagSet] |
| 866 | |
| 867 | except KeyError: |
| 868 | raise error.PyAsn1Error('No encoder for %r (%s)' % (value, tagSet)) |
| 869 | |
| 870 | if LOG: |
| 871 | LOG('using value codec %s chosen by tagSet ' |
| 872 | '%s' % (concreteEncoder.__class__.__name__, tagSet)) |
| 873 | |
| 874 | substrate = concreteEncoder.encode(value, asn1Spec, self, **options) |
| 875 | |
| 876 | if LOG: |
| 877 | LOG('codec %s built %s octets of substrate: %s\nencoder ' |
| 878 | 'completed' % (concreteEncoder, len(substrate), |
| 879 | debug.hexdump(substrate))) |
| 880 | |
| 881 | return substrate |
nothing calls this directly
no test coverage detected