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

Method __call__

pager_lib/pyasn1/codec/native/encoder.py:193–230  ·  view source on GitHub ↗
(self, value, **options)

Source from the content-addressed store, hash-verified

191 self._typeMap = typeMap if typeMap is not _MISSING else self.TYPE_MAP
192
193 def __call__(self, value, **options):
194 if not isinstance(value, base.Asn1Item):
195 raise error.PyAsn1Error(
196 'value is not valid (should be an instance of an ASN.1 Item)')
197
198 if LOG:
199 debug.scope.push(type(value).__name__)
200 LOG('encoder called for type %s '
201 '<%s>' % (type(value).__name__, value.prettyPrint()))
202
203 tagSet = value.tagSet
204
205 try:
206 concreteEncoder = self._typeMap[value.typeId]
207
208 except KeyError:
209 # use base type for codec lookup to recover untagged types
210 baseTagSet = tag.TagSet(
211 value.tagSet.baseTag, value.tagSet.baseTag)
212
213 try:
214 concreteEncoder = self._tagMap[baseTagSet]
215
216 except KeyError:
217 raise error.PyAsn1Error('No encoder for %s' % (value,))
218
219 if LOG:
220 LOG('using value codec %s chosen by '
221 '%s' % (concreteEncoder.__class__.__name__, tagSet))
222
223 pyObject = concreteEncoder.encode(value, self, **options)
224
225 if LOG:
226 LOG('encoder %s produced: '
227 '%s' % (type(concreteEncoder).__name__, repr(pyObject)))
228 debug.scope.pop()
229
230 return pyObject
231
232
233class Encoder(object):

Callers

nothing calls this directly

Calls 4

pushMethod · 0.80
popMethod · 0.80
prettyPrintMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected