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

Method __call__

pager_lib/pyasn1/codec/ber/decoder.py:1563–1905  ·  view source on GitHub ↗
(self, substrate, asn1Spec=None,
                 tagSet=None, length=None, state=stDecodeTag,
                 decodeFun=None, substrateFun=None,
                 **options)

Source from the content-addressed store, hash-verified

1561 self._tagSetCache = {}
1562
1563 def __call__(self, substrate, asn1Spec=None,
1564 tagSet=None, length=None, state=stDecodeTag,
1565 decodeFun=None, substrateFun=None,
1566 **options):
1567
1568 allowEoo = options.pop('allowEoo', False)
1569
1570 if LOG:
1571 LOG('decoder called at scope %s with state %d, working with up '
1572 'to %s octets of substrate: '
1573 '%s' % (debug.scope, state, length, substrate))
1574
1575 # Look for end-of-octets sentinel
1576 if allowEoo and self.supportIndefLength:
1577
1578 for eoo_candidate in readFromStream(substrate, 2, options):
1579 if isinstance(eoo_candidate, SubstrateUnderrunError):
1580 yield eoo_candidate
1581
1582 if eoo_candidate == EOO_SENTINEL:
1583 if LOG:
1584 LOG('end-of-octets sentinel found')
1585 yield eoo.endOfOctets
1586 return
1587
1588 else:
1589 substrate.seek(-2, os.SEEK_CUR)
1590
1591 tagMap = self._tagMap
1592 typeMap = self._typeMap
1593 tagCache = self._tagCache
1594 tagSetCache = self._tagSetCache
1595
1596 value = noValue
1597
1598 substrate.markedPosition = substrate.tell()
1599
1600 while state is not stStop:
1601
1602 if state is stDecodeTag:
1603 # Decode tag
1604 isShortTag = True
1605
1606 for firstByte in readFromStream(substrate, 1, options):
1607 if isinstance(firstByte, SubstrateUnderrunError):
1608 yield firstByte
1609
1610 firstOctet = ord(firstByte)
1611
1612 try:
1613 lastTag = tagCache[firstOctet]
1614
1615 except KeyError:
1616 integerTag = firstOctet
1617 tagClass = integerTag & 0xC0
1618 tagFormat = integerTag & 0x20
1619 tagId = integerTag & 0x1F
1620

Callers

nothing calls this directly

Calls 12

readFromStreamFunction · 0.90
PyAsn1ErrorClass · 0.90
popMethod · 0.80
seekMethod · 0.80
tellMethod · 0.80
pushMethod · 0.80
itemsMethod · 0.45
prettyPrintTypeMethod · 0.45
getMethod · 0.45
indefLenValueDecoderMethod · 0.45
valueDecoderMethod · 0.45
prettyPrintMethod · 0.45

Tested by

no test coverage detected