<s> class NodeBase : <EOL> def __init__ ( self , repo , content ) : <EOL> self . repo = repo <EOL> self . content = self . shrink ( content ) <EOL> def __bytes__ ( self ) : <EOL> return ( "<STR_LIT>" % ( self . __class__ , self . content ) ) . encode ( "<STR_LIT:utf-8>" ) <EOL> class Atom ( NodeBase ) : <EOL> def shrink ( self , content ) : <EOL> return content <EOL> def expand ( self ) : <EOL> return self . content <EOL> class Dictionary ( NodeBase ) : <EOL> def shrink ( self , content ) : <EOL> return { <EOL> self . repo . shrink ( key ) : self . repo . shrink ( value ) <EOL> for key , value in content . items ( ) <EOL> } <EOL> def expand ( self ) : <EOL> return { <EOL> self . repo . expand ( key ) : self . repo . expand ( value ) <EOL> for key , value in self . content . items ( ) <EOL> } <EOL> class List ( NodeBase ) : <EOL> def shrink ( self , content ) : <EOL> return [ self . repo . shrink ( item ) for item in content ] <EOL> def expand ( self ) : <EOL> return [ self . repo . expand ( item ) for item in self . content ] <EOL> class Tuple ( NodeBase ) : <EOL> def shrink ( self , content ) : <EOL> return tuple ( self . repo . shrink ( item ) for item in content ) <EOL> def expand ( self ) : <EOL> return tuple ( self . repo . expand ( item ) for item in self . content ) <EOL> def wrap ( repo , content ) : <EOL> if isinstance ( content , dict ) : <EOL> return Dictionary ( repo , content ) <EOL> elif isinstance ( content , list ) : <EOL> return List ( repo , content ) <EOL> elif isinstance ( content , tuple ) : <EOL> return Tuple ( repo , content ) <EOL> else : <EOL> return Atom ( repo , content ) </s>
