<s> from __future__ import absolute_import <EOL> from . base import * <EOL> class MetaStrict ( type ) : <EOL> def __new__ ( cls , clsname , bases , methods ) : <EOL> for k , v in methods . items ( ) : <EOL> if isinstance ( v , Descriptor ) : <EOL> v . name = k <EOL> return type . __new__ ( cls , clsname , bases , methods ) <EOL> class MetaSerialisable ( type ) : <EOL> def __new__ ( cls , clsname , bases , methods ) : <EOL> attrs = [ ] <EOL> nested = [ ] <EOL> elements = [ ] <EOL> namespaced = [ ] <EOL> for k , v in methods . items ( ) : <EOL> if isinstance ( v , Descriptor ) : <EOL> ns = getattr ( v , '<STR_LIT>' , None ) <EOL> if ns : <EOL> namespaced . append ( ( k , "<STR_LIT>" % ( ns , k ) ) ) <EOL> if getattr ( v , '<STR_LIT>' , False ) : <EOL> nested . append ( k ) <EOL> elements . append ( k ) <EOL> elif isinstance ( v , Sequence ) : <EOL> elements . append ( k ) <EOL> elif isinstance ( v , Typed ) : <EOL> if hasattr ( v . expected_type , '<STR_LIT>' ) : <EOL> elements . append ( k ) <EOL> else : <EOL> attrs . append ( k ) <EOL> else : <EOL> if not isinstance ( v , Alias ) : <EOL> attrs . append ( k ) <EOL> if methods . get ( '<STR_LIT>' ) is None : <EOL> methods [ '<STR_LIT>' ] = tuple ( attrs ) <EOL> methods [ '<STR_LIT>' ] = tuple ( namespaced ) <EOL> if methods . get ( '<STR_LIT>' ) is None : <EOL> methods [ '<STR_LIT>' ] = tuple ( sorted ( nested ) ) <EOL> if methods . get ( '<STR_LIT>' ) is None : <EOL> methods [ '<STR_LIT>' ] = tuple ( sorted ( elements ) ) <EOL> return MetaStrict . __new__ ( cls , clsname , bases , methods ) <EOL> Strict = MetaStrict ( '<STR_LIT>' , ( object , ) , { } ) <EOL> _Serialiasable = MetaSerialisable ( '<STR_LIT>' , ( object , ) , { } ) </s>
