<s> from . import serializable <EOL> from . . util import none_or <EOL> class Namespace ( serializable . Type ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = ( '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self , id , name , canonical = None , aliases = None , case = None , <EOL> content = False ) : <EOL> self . id = int ( id ) <EOL> """<STR_LIT>""" <EOL> self . name = none_or ( name , str ) <EOL> """<STR_LIT>""" <EOL> self . aliases = serializable . Set . deserialize ( aliases or [ ] , str ) <EOL> """<STR_LIT>""" <EOL> self . case = none_or ( case , str ) <EOL> """<STR_LIT>""" <EOL> self . canonical = none_or ( canonical , str ) <EOL> """<STR_LIT>""" <EOL> self . content = bool ( content ) <EOL> """<STR_LIT>""" <EOL> def __hash__ ( self ) : <EOL> return self . id <EOL> @ classmethod <EOL> def from_doc ( cls , doc , aliases = { } ) : <EOL> """<STR_LIT>""" <EOL> return cls ( <EOL> doc [ '<STR_LIT:id>' ] , <EOL> doc [ '<STR_LIT:*>' ] , <EOL> canonical = doc . get ( '<STR_LIT>' ) , <EOL> aliases = set ( aliases . get ( doc [ '<STR_LIT:id>' ] , [ ] ) ) , <EOL> case = doc [ '<STR_LIT>' ] , <EOL> content = '<STR_LIT:content>' in doc <EOL> ) </s>
