<s> from operator import getitem <EOL> from pyasn1 import error <EOL> tagClassUniversal = <NUM_LIT> <EOL> tagClassApplication = <NUM_LIT> <EOL> tagClassContext = <NUM_LIT> <EOL> tagClassPrivate = <NUM_LIT> <EOL> tagFormatSimple = <NUM_LIT> <EOL> tagFormatConstructed = <NUM_LIT> <EOL> tagCategoryImplicit = <NUM_LIT> <EOL> tagCategoryExplicit = <NUM_LIT> <EOL> tagCategoryUntagged = <NUM_LIT> <EOL> class Tag : <EOL> def __init__ ( self , tagClass , tagFormat , tagId ) : <EOL> if tagId < <NUM_LIT:0> : <EOL> raise error . PyAsn1Error ( <EOL> '<STR_LIT>' % ( tagId , ) <EOL> ) <EOL> self . __tag = ( tagClass , tagFormat , tagId ) <EOL> self . uniq = ( tagClass , tagId ) <EOL> self . __hashedUniqTag = hash ( self . uniq ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % self . __tag <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( <EOL> ( self . __class__ . __name__ , ) + self . __tag <EOL> ) <EOL> def __eq__ ( self , other ) : return self . uniq == other . uniq <EOL> def __ne__ ( self , other ) : return self . uniq != other . uniq <EOL> def __lt__ ( self , other ) : return self . uniq < other . uniq <EOL> def __le__ ( self , other ) : return self . uniq <= other . uniq <EOL> def __gt__ ( self , other ) : return self . uniq > other . uniq <EOL> def __ge__ ( self , other ) : return self . uniq >= other . uniq <EOL> def __hash__ ( self ) : return self . __hashedUniqTag <EOL> def __getitem__ ( self , idx ) : return self . __tag [ idx ] <EOL> def __and__ ( self , otherTag ) : <EOL> ( tagClass , tagFormat , tagId ) = otherTag <EOL> return self . __class__ ( <EOL> self . __tag & tagClass , self . __tag & tagFormat , self . __tag & tagId <EOL> ) <EOL> def __or__ ( self , otherTag ) : <EOL> ( tagClass , tagFormat , tagId ) = otherTag <EOL> return self . __class__ ( <EOL> self . __tag [ <NUM_LIT:0> ] | tagClass , <EOL> self . __tag [ <NUM_LIT:1> ] | tagFormat , <EOL> self . __tag [ <NUM_LIT:2> ] | tagId <EOL> ) <EOL> def asTuple ( self ) : return self . __tag <EOL> class TagSet : <EOL> def __init__ ( self , baseTag = ( ) , * superTags ) : <EOL> self . __baseTag = baseTag <EOL> self . __superTags = superTags <EOL> self . __hashedSuperTags = hash ( superTags ) <EOL> _uniq = ( ) <EOL> for t in superTags : <EOL> _uniq = _uniq + t . uniq <EOL> self . uniq = _uniq <EOL> self . __lenOfSuperTags = len ( superTags ) <EOL> def __str__ ( self ) : <EOL> return self . __superTags and '<STR_LIT:+>' . join ( [ str ( x ) for x in self . __superTags ] ) or '<STR_LIT>' <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( <EOL> self . __class__ . __name__ , <EOL> '<STR_LIT>' + '<STR_LIT:U+002CU+0020>' . join ( [ repr ( x ) for x in self . __superTags ] ) <EOL> ) <EOL> def __add__ ( self , superTag ) : <EOL> return self . __class__ ( <EOL> self . __baseTag , * self . __superTags + ( superTag , ) <EOL> ) <EOL> def __radd__ ( self , superTag ) : <EOL> return self . __class__ ( <EOL> self . __baseTag , * ( superTag , ) + self . __superTags <EOL> ) <EOL> def tagExplicitly ( self , superTag ) : <EOL> tagClass , tagFormat , tagId = superTag <EOL> if tagClass == tagClassUniversal : <EOL> raise error . PyAsn1Error ( <EOL> '<STR_LIT>' <EOL> ) <EOL> if tagFormat != tagFormatConstructed : <EOL> superTag = Tag ( tagClass , tagFormatConstructed , tagId ) <EOL> return self + superTag <EOL> def tagImplicitly ( self , superTag ) : <EOL> tagClass , tagFormat , tagId = superTag <EOL> if self . __superTags : <EOL> superTag = Tag ( tagClass , self . __superTags [ - <NUM_LIT:1> ] [ <NUM_LIT:1> ] , tagId ) <EOL> return self [ : - <NUM_LIT:1> ] + superTag <EOL> def getBaseTag ( self ) : return self . __baseTag <EOL> def __getitem__ ( self , idx ) : <EOL> if isinstance ( idx , slice ) : <EOL> return self . __class__ ( <EOL> self . __baseTag , * getitem ( self . __superTags , idx ) <EOL> ) <EOL> return self . __superTags [ idx ] <EOL> def __eq__ ( self , other ) : return self . uniq == other . uniq <EOL> def __ne__ ( self , other ) : return self . uniq != other . uniq <EOL> def __lt__ ( self , other ) : return self . uniq < other . uniq <EOL> def __le__ ( self , other ) : return self . uniq <= other . uniq <EOL> def __gt__ ( self , other ) : return self . uniq > other . uniq <EOL> def __ge__ ( self , other ) : return self . uniq >= other . uniq <EOL> def __hash__ ( self ) : return self . __hashedSuperTags <EOL> def __len__ ( self ) : return self . __lenOfSuperTags <EOL> def isSuperTagSetOf ( self , tagSet ) : <EOL> if len ( tagSet ) < self . __lenOfSuperTags : <EOL> return <EOL> idx = self . __lenOfSuperTags - <NUM_LIT:1> <EOL> while idx >= <NUM_LIT:0> : <EOL> if self . __superTags [ idx ] != tagSet [ idx ] : <EOL> return <EOL> idx = idx - <NUM_LIT:1> <EOL> return <NUM_LIT:1> <EOL> def initTagSet ( tag ) : return TagSet ( tag , tag ) </s>
