<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> from marshmallow . exceptions import RegistryError <EOL> _registry = { } <EOL> def register ( classname , cls ) : <EOL> """<STR_LIT>""" <EOL> module = cls . __module__ <EOL> fullpath = '<STR_LIT:.>' . join ( [ module , classname ] ) <EOL> if classname in _registry and not any ( each . __module__ == module for each in _registry [ classname ] ) : <EOL> _registry [ classname ] . append ( cls ) <EOL> else : <EOL> _registry [ classname ] = [ cls ] <EOL> _registry . setdefault ( fullpath , [ ] ) . append ( cls ) <EOL> return None <EOL> def get_class ( classname , all = False ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> classes = _registry [ classname ] <EOL> except KeyError : <EOL> raise RegistryError ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( classname ) ) <EOL> if len ( classes ) > <NUM_LIT:1> : <EOL> if all : <EOL> return _registry [ classname ] <EOL> raise RegistryError ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( classname ) ) <EOL> else : <EOL> return _registry [ classname ] [ <NUM_LIT:0> ] </s>
