home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / gdata / tlslite / utils / ASN1Parser.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.5 KB  |  36 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Class for parsing ASN.1'''
  5. from compat import *
  6. from codec import *
  7.  
  8. class ASN1Parser:
  9.     
  10.     def __init__(self, bytes):
  11.         p = Parser(bytes)
  12.         p.get(1)
  13.         self.length = self._getASN1Length(p)
  14.         self.value = p.getFixBytes(self.length)
  15.  
  16.     
  17.     def getChild(self, which):
  18.         p = Parser(self.value)
  19.         for x in range(which + 1):
  20.             markIndex = p.index
  21.             p.get(1)
  22.             length = self._getASN1Length(p)
  23.             p.getFixBytes(length)
  24.         
  25.         return ASN1Parser(p.bytes[markIndex:p.index])
  26.  
  27.     
  28.     def _getASN1Length(self, p):
  29.         firstLength = p.get(1)
  30.         if firstLength <= 127:
  31.             return firstLength
  32.         lengthLength = firstLength & 127
  33.         return p.get(lengthLength)
  34.  
  35.  
  36.